Last updated on: 2019-11-25 Authored by: Afrinet Telecom Limited API Endpoint URL: "https://bulksms.afrinettelecom.co.ke/api/services/sendsms/" Below is a sample send sms client ... in PHP:
URL:"https://bulksms.afrinettelecom.co.ke/api/services/sendsms/?"
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://bulksms.afrinettelecom.co.ke/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";
SAMPLE REQUEST BODY
{
"apikey":"123456789",
"partnerID":"123",
"message":"this is a test message",
"shortcode":"SENDERID",
"mobile":"254712345678"
}
URL: "https://bulksms.afrinettelecom.co.ke/api/services/sendsms/"
$url = 'https://bulksms.afrinettelecom.co.ke/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);
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
$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";
}
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"
}
$url = 'https://bulksms.afrinettelecom.co.ke/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);
$url = 'https://bulksms.afrinettelecom.co.ke/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);