SMS API Documentation

SMS API - REST interface

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

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

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

Example script in PHP


1. Send 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. Send 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!