Our API is built to accept JSON requests.
{ "username":"xxxxxx", "password":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx", "mobile":"254712345678", "amount":"10", "client_ref":6325 }
Follow this Request Instructions:
function sendAirtime($mobile, $amount) { $username = "YOURUSERNAME"; $password = base64_encode(md5("YOURPASSWORD")); $client_ref = rand(1000, 9999); $airtime_data = array("username" => $username, "password" => $password, "mobile" => $mobile, "amount" => $amount, "client_ref" => $client_ref); $airtime_string = json_encode($airtime_data); $URL = "https://isms.advantasms.com/isms/api/sendAirtime"; //POST $ch = curl_init($URL); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $airtime_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($airtime_string)) ); $apiresult = curl_exec($ch); echo("API Response: $apiresult\n"); if (!$apiresult) { die("ERROR on URL[$URL] | error[" . curl_error($ch) . "] | error code[" . curl_errno($ch) . "]\n"); } curl_close($ch); }