$username, 'password'=>$password, 'sender'=>$sender, 'message'=>$message, 'mobiles'=>$mobiles); //URL encode the message data $data = http_build_query($data); //Send the message $ch = curl_init(); // Initialize a cURL connection curl_setopt($ch,CURLOPT_URL, $api_url); curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); curl_setopt($ch,CURLOPT_POST, true); curl_setopt($ch,CURLOPT_POSTFIELDS, $data); $result = curl_exec($ch); $result = json_decode($result); if(isset($result->status) && strtoupper($result->status) == 'OK') { // Message sent successfully, do anything here echo 'Message sent at N'.$result->price; } else if(isset($result->error)) { // Message failed, check reason. echo 'Message failed - error: '.$result->error; } else { // Could not determine the message response. echo 'Unable to process request'; } ?>