USSD (GET/POST) - Submit USSD Query
This endpoint allows you submit USSD query to a specific server.
Base URL
https://ussd.simhosting.ng/api/ussd/
Submit USSD requests to 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.
USSD PARAMETERS
Parameter | Type | Description |
---|---|---|
ussd | string | The USSD query to run |
multistep | string | Optional. This option is for Multi-Step USSD. Supply the responses in order you would like it dialed separated by comma. |
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 Code to send USSD Request through HTTPS POST call to the USSD API
<?php
$baseurl = "https://ussd.simhosting.ng/api/ussd/?";
$ussdArray = array (
"ussd"=> "USSD_CODE_REQUEST_HERE",
"multistep"=> "COMMA_SEPARATED_REPLIES_FOR_MULTISTEP_USSD",
"servercode" => "SIMSERVER_TOKEN_HERE",
"token" =>"API_TOKEN_HERE",
"refid" =>"YOUR_CUSTOM_ID"
);
$params = http_build_query($ussdArray);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$baseurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch); curl_close($ch);
echo $response; // response code
?>
USSD Request Format (HTTPS GET Method)
Snippet to a USSD query to a hosted SIM.
<?php
$servercode = "SERVER_CODE";
$token = "API_TOKEN";
$ussd_refid = "CUSTOM_REFID";
$ussd_base = "http://ussd.simhosting.ng/api/ussd/?";
$ussd_query = "USSD_QUERY";
$multistep = "COMMA_SEPARATED_REPLIES_FOR_MULTISTEP_USSD";
$ussd_data = array("servercode"=>$servercode, "token"=>$token, "ussd"=>$ussd_query, "multistep"=>$multistep, "refid"=>$ussd_refid);
$ussd_url = $ussd_base.http_build_query($ussd_data);
$run = file_get_contents($ussd_url);
echo $run;
?>
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"
}