Documentation

REST SMS API Interface

The simplicity of implementation makes REST API Interface most often used method of integration with SMSAPI service.

Using REST API you are able to integrate any software or web application with SMSAPI service.

File name: Version: Updated on: Download
REST API Documentation - basic functions Version: 1.1 Updated on: 26.08.2015 Download
REST API Documentation - external functions Version: 1.0 Updated on: 08.07.2015 Download
  Availability of our services can be monitored at status.smapi.com.

Example script in PHP


1. Sending SMS message using OAuth



<?php
    
function sms_send($params$token$backup false ) {

        static 
$content;

        if(
$backup == true){
            
$url 'https://api2.smsapi.com/sms.do';
        }else{
            
$url 'https://api.smsapi.com/sms.do';
        }

        
$c curl_init();
        
curl_setopt$cCURLOPT_URL$url );
        
curl_setopt$cCURLOPT_POSTtrue );
        
curl_setopt$cCURLOPT_POSTFIELDS$params );
        
curl_setopt$cCURLOPT_RETURNTRANSFERtrue );
        
curl_setopt$cCURLOPT_HTTPHEADER, array(
           
"Authorization: Bearer $token"
        
));

        
$content curl_exec$c );
        
$http_status curl_getinfo($cCURLINFO_HTTP_CODE);

        if(
$http_status != 200 && $backup == false){
            
$backup true;
            
sms_send($params$token$backup);
        }

        
curl_close$c );
        return 
$content;
    }

    
$token "generated_token";
    
$params = array(
         
'to' => '500000000',
    
'from' => 'Info',
    
'message' => "Hello world!",
    );

    echo 
sms_send($params,$token);
?>


2. Sending SMS message using login and API password


    
<?php
    
function sms_send($params$backup false ) {

        static 
$content;

        if(
$backup == true){
            
$url 'https://api2.smsapi.com/sms.do';
        }else{
            
$url 'https://api.smsapi.com/sms.do';
        }

        
$c curl_init();
        
curl_setopt$cCURLOPT_URL$url );
        
curl_setopt$cCURLOPT_POSTtrue );
        
curl_setopt$cCURLOPT_POSTFIELDS$params );
        
curl_setopt$cCURLOPT_RETURNTRANSFERtrue );

        
$content curl_exec$c );
        
$http_status curl_getinfo($cCURLINFO_HTTP_CODE);

        if(
$http_status != 200 && $backup == false){
            
$backup true;
            
sms_send($params$backup);
        }

        
curl_close$c );
        return 
$content;
    }

    
$params = array(
         
'username' => 'login',
    
'password' => 'password-md5',
    
'to' => '500000000',
    
'from' => 'SMSAPI',
    
'eco' => 0,
    
'message' => "My message",
    );

    echo 
sms_send($params);
?>

Register for free

Sign-up in 30 seconds and get Free SMS for tests!


Let's talk