Afrinet Telecoms Enabling Solid Customer Relations

Integrations Bulk SMS

  • Home
  • Integrations Bulk SMS
image
image
image
image
Overview

Last updated on: 2019-11-25 Authored by: Afrinet Telecom Limited API Endpoint URL: "https://sms.imarabiz.com/api/services/sendsms/" Below is a sample send sms client ... in PHP:

# GET METHOD
                                
URL:"https://sms.imarabiz.com/api/services/sendsms/?" 
# GET PARAMS

apikey : Valid API KEY. Get this by clicking the GET API KEY
partnerID : Valid Partner ID. Get this by clicking the PARTNER ID
message : URL Encoded Text Message with valid GSM7 Characters
shortcode : Valid Sender ID / Shortcode
mobile : Valid Mobile Number

                                
$partnerID = "useraccountpartnerId";
$apikey = "useraccountapikey";
$shortcode = "INFOTEXT";

$mobile = "254712345678"; // Bulk messages can be comma separated
$message = "This is a test message + = # special characters @ _ -";

$finalURL = "https://sms.imarabiz.com/api/services/sendsms/?apikey=" . urlencode($apikey) . "&partnerID=" . urlencode($partnerID) . "&message=" . urlencode($message) . "&shortcode=$shortcode&mobile=$mobile";
$ch = curl_init();
\curl_setopt($ch, CURLOPT_URL, $finalURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
echo "Response: $response";

                                
                            
POST METHOD

SAMPLE REQUEST BODY

                                
{
  "apikey":"123456789",
  "partnerID":"123",
  "message":"this is a test message",
  "shortcode":"SENDERID",
  "mobile":"254712345678"
}

                                
                            
# REQUEST ENDPOINT:

URL: "https://sms.imarabiz.com/api/services/sendsms/"

                                
$url = 'https://sms.imarabiz.com/api/services/sendsms/';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); //setting custom header


$curl_post_data = array(
      //Fill in the request parameters with valid values
     'partnerID' => '00',
     'apikey' => 'xxxxxxxxxxx',
     'mobile' => '0712345678',
     'message' => 'This is a test message',
     'shortcode' => 'INFOTEXT',
     'pass_type' => 'plain', //bm5 {base64 encode} or plain
);

$data_string = json_encode($curl_post_data);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);

$curl_response = curl_exec($curl);
print_r($curl_response);

                                
                            
# SAMPLE RESPONSE

For a successfully sent message you get:

                                
{"responses":[{"respose-code":200,"response-description":"Success","mobile":254713482448,"messageid":8290842,"networkid":"1"}]}

                                
                            

where 8290842 is the message id. This is the message id to use when querying delivery reports

# HOW TO READ THE RESPONSE (PHP)
                                
$response = '{"responses":[{"response-code":200,"response-description":"Success","mobile":254713482448,"messageid":8290842,"networkid":"1"},{"respose-code":200,"response-description":"Success","mobile":254713482448,"messageid":8290843,"networkid":"1"}]}';

$count = 0;

if ($response != null) {
    $responseData = json_decode($response, TRUE);
    foreach ($responseData as $responseItem) {
        foreach ($responseItem as $smsdetails) {
            $messageID = $responseData['responses'][$count]['messageid'];
            $count++;
        }
    }
} else {
    echo "Null Response";
}

                                
                            
# SCHEDULING MESSAGES

For messages to be sent at a future time, you will need to pass an optional parameter timeToSend with a valid date string that resolves to a Unix timestamp or the unix timestamp itself.

                                
{
"apikey":"123456789",
"partnerID":"123",
"message":"this is a test message",
"shortcode":"SENDERID",
"mobile":"254712345678",
"timeToSend":"2019-09-01 18:00"
}
                                
                            
# GETTING DELIVERY REPORTS Example below is in PHP.
                                
$url = 'https://sms.imarabiz.com/api/services/getdlr/';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); //setting custom header


$curl_post_data = array(
//Fill in the request parameters with valid values
'partnerID' => '00',
'apikey' => 'xxxxxxxxxxxxx',
'messageID' => '123456789',
);

$data_string = json_encode($curl_post_data);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);

$curl_response = curl_exec($curl);
print_r($curl_response);

                                
                            
# GETTING ACCOUNT BALANCE Example below is in PHP.
                                
$url = 'https://sms.imarabiz.com/api/services/getbalance/';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); //setting custom header


$curl_post_data = array(
//Fill in the request parameters with valid values
'partnerID' => '00',
'apikey' => 'xxxxxxxxxxxxx',
);

$data_string = json_encode($curl_post_data);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);

$curl_response = curl_exec($curl);
print_r($curl_response);


                                
                            
# API RETURN CODES / DESCRIPTION
  • 200: Successful Request Call
  • 1001: Invalid sender id
  • 1002: Network not allowed
  • 1003: Invalid mobile number
  • 1004: Low bulk credits
  • 1005: Failed. System error
  • 1006: Invalid credentials
  • 1007: Failed. System error
  • 1008: No Delivery Report
  • 1009: unsupported data type
  • 1010: unsupported request type
  • 4090: Internal Error. Try again after 5 minutes
  • 4091: No Partner ID is Set
  • 4092: No API KEY Provided
  • 4093: Details Not Found