SHORTCODE (GET/POST) - Submit a Shortcode Message

This endpoint allows you submit a shortcode message to its destination.

Base URL

https://ussd.simhosting.ng/api/shortcode/

Submit the shortcode message to its destination via the base URL. All the requests are submitted through HTTPS POST/GET method. Although you can use HTTP protocol, we strongly recommend you to submit all requests to API over HTTPS so the traffic is encrypted and the privacy is ensured.

Examples

1. To sell 2GB SME data: Text SMED 08000000000 2000 1234 to 131

2. To check data balance: Text 2 to 131

 

USSD PARAMETERS

Parameter Type Description
shortcode string The destination for the shortcode message. eg. 131, 777, 141, etc
message string The content of the message
servercode string The SIMServer token. This can be obtained from My Hosted SIMs page.
token string The API authentication token. This can be accessed from API Tokens' page
refid string Optional. Your custom reference code. This is returned on a successful submission. It must be unique. The maximum length is 50 characters.
 

USSD Request Format (HTTPS POST Method)

Sample PHP code to send shortcode request through HTTPS POST call to the API


<?php
    $baseurl 
"https://ussd.simhosting.ng/api/shortcode/?";
    
$shortcode_array = array (
      
"shortcode"=> "THE_SHORTCODE_DESTINATION",
      
"message"=>"THE_MESSAGE_CONTENT",
      
"servercode" => "SIMSERVER_TOKEN_HERE",
      
"token" =>"API_TOKEN_HERE",
      
"refid" =>"YOUR_CUSTOM_ID"
    
     
); 
    
$params http_build_query($shortcode_array); 
    
$ch curl_init(); 
    
curl_setopt($chCURLOPT_URL,$baseurl); 
    
curl_setopt($chCURLOPT_RETURNTRANSFER,true); 
    
curl_setopt($chCURLOPT_POST1); 
    
curl_setopt($chCURLOPT_POSTFIELDS$params); 
    
$response curl_exec($ch); curl_close($ch); 
    echo 
$response// response code 
?>

USSD Request Format (HTTPS GET Method)

Sample PHP code to send shortcode request through HTTPS GET call to the API

 

<?php
    $baseurl 
"https://ussd.simhosting.ng/api/shortcode/?";
    
$shortcode_array = array (
      
"shortcode"=> "THE_SHORTCODE_DESTINATION",
      
"message"=>"THE_MESSAGE_CONTENT",
      
"servercode" => "SIMSERVER_TOKEN_HERE",
      
"token" =>"API_TOKEN_HERE",
      
"refid" =>"YOUR_CUSTOM_ID"
    
     
); 
    
$shortcode_url $ussd_base.http_build_query($shortcode_array);
    
$response file_get_contents($shortcode_url);
    echo 
$response// response code 
?>

 

USSD Response Format

All response are in the format below:

{json data}

 

Response on Success

{
"success": "true",
"comment": "ADDITIONAL_COMMENT",
"refid": "SUPPLIED_REFID",
"log_id": "SERVER_LOG_ID" }

 The refid and the log_id can be used to call the status of the query using the status API endpoint.

Response on Failure

{
"success": "false",
"comment": "ADDITIONAL_COMMENT"
}

 

Tags
Image

USSD on SIMHosting is a product of HoRLaR I.T. Solutions. It automates data and airtime vending via HTTPS POST/GET requests to the hosted SIM.