Step by step guide of using tiniyo sms with php and apache. after end of this blog you guys are able to send SMS all around the world.

Install Apache & PHP on Ubuntu 20.04

Apache and php is available within Ubuntu’s default software repositories, so you can install it using conventional package management tools.

Update your local package index:

sudo apt update

Install the apache2 and php package:

sudo apt install apache2 php libapache2-mod-php

Send SMS using php curl

Following is sample code for sending tiniyo sms using php. You need AuthID and AuthSecretID of tiniyo to send SMS. You can Signup and get AuthID and AuthSecretID from dashboard.

Using following code create tiniyosmstest.php file on your home folder. and replace {AuthID} and {AuthSecretID} with valid tiniyo credentials. Replace XXXXXXXXXX with valid phone number with international code. For the developer account this should be same phone number you used at time of signup OTP verification.

This code uses SMS API for sending SMS. You can TRY this api on webpage as well.


$url = '{AuthID}/Message';

//create a new cURL resource
$ch = curl_init($url);

// curl_setopt($ch, CURLOPT_VERBOSE, true);

//setup request to send json via POST
$data = array(
    'src' => 'TINIYO',
    'dst' => 'XXXXXXXXXXXX',
    'text' => 'Hello Tiniyo'

$payload = json_encode($data);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, '{AuthID}:{AuthSecretID}' );
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

//attach encoded JSON string to the POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

// Set HTTP Header for POST request
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($payload))

//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//execute the POST request
$returns = curl_exec($ch);

// check the HTTP Status code
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
switch ($httpCode) {
	case 200: 
		$resp = json_decode($returns);
		if ($resp->status) {
			echo "Status: ".$resp->status." MessageID: ".$resp->msgid." Message:".$resp->message."\n";
			if ( $resp->status == "success" ) {
				echo "Message sent successfully\n";
		} else {
			echo "Message sent Failed\n";	
		echo 'Http Error: ' . $httpCode . ' : ' . curl_error($ch);

//close cURL resource


Run this code using following command. You should get SMS on your cell phone.

user@pc:~$php tiniyosmstest.php

PHP Deployed on apache server
will be available soon...