#!/usr/local/bin/php $ACCID, // Account Id 'PinCode' => $PINCODE, // Pin code 'MsgTxt' => $MESSAGE, // Message to sent 'SendFrom' => $SENDFROM, // Send from // 'Destination' => $DESTINATION, // Send SMS to the one destination 'Destination' => $DEST_LIST, // Send SMS to the list of destinations ); // Do sending $res = sendRequest('send', $params); if ($res['ErrCode']) { // Fail print "Error: ".$res['ErrMsg']."\n"; // Error message if ($res['ErrCode'] == 'INVDEST') { // Load list of invalid destinations if available if (is_array($res['InvalidDestinations'])) { print "List of invalid phone numbers:\n".implode("\n", $res['InvalidDestinations'])."\n"; } else if ($res['InvalidDestinations']) { print "Invalid phone number: ".$res['InvalidDestinations']."\n"; } } } else { // Success $SENDIGNID = $res['SendingId']; print "Message Sent. Id for checking status: ".$res['SendingId']."\n"; } // // Check SMS sending status // print "Check SMS sending status\n"; $params = array ('AccId' => $ACCID, // Account Id 'PinCode' => $PINCODE, // Pin code 'SendingId' => $SENDIGNID); // Sending Id // Do sending $res = sendRequest('status',$params); if ($res['ErrCode']) { // Fail print "Error: ".$res['ErrMsg']."\n"; // Error message } else { // Success print "Queue: ".$res['Queue']."\n". "Sent: ".$res['Sent']."\n". "Delivered: ".($res['Delivered'] ? $res['Delivered'] : 'N/A')."\n". "Failed: ".$res['Failed']."\n". "Cost: ".$res['Cost'].' '.$res['Currency']."\n"; } exit; // // sendRequest - send request using NuSOAP lib // function sendRequest($func,$params) { global $WSDL; $client = new soapclient($WSDL, 'wsdl'); $err = $client->getError(); if ($err) { print "Constructor error: $err\n"; return array('ErrMsg' => $err, 'ErrCode' => 'ERR'); } $result = $client->call($func, array('inParams' => $params)); if ($client->fault) { // Check for a fault print "Fault\n". print_r($result); return array('ErrMsg' => 'Request failed', 'ErrCode' => 'ERR'); } else { $err = $client->getError(); // Check for errors if ($err) { // Display the error return array('ErrMsg' => $err, 'ErrCode' => 'ERR'); } } return $result[out]; } ?>