The code below was used to send sms but i need to be able to return values for every action
for instance if sms is ok return value successful, if value is 2904 return SMS sending failed etc.
Any help will be appreciated.
The return values of SMS gateway API are as follows:
Code:OK=Successful 2904=SMS Sending Failed 2905=Invalid username/password combination 2906=Credit exhausted <?php $data = array( 'username' => $_GET['username'], 'password' => $_GET['password'], 'sender' => $_GET['sender'], // 'sender' => $_GET['uname'], 'recipient' => $_GET['recipient'], 'message' => $_GET['message'] ); // Send the POST request with cURL $ch = curl_init('http://example.com/components/com_spc/smsapi.php'); curl_setopt($ch, CURLOPT_POST, true); $header[ ] = "Accept: text/xml,application/xml,application/xhtml+xml,"; $header[ ] = "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[ ] = "Cache-Control: max-age=0"; $header[ ] = "Connection: keep-alive"; $header[ ] = "Keep-Alive: 300"; $header[ ] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[ ] = "Accept-Language: en-us,en;q=0.5"; $header[ ] = "Pragma: "; // browsers keep this blank. // also tried $header[] = "Accept: text/html"; curl_setopt ($ch, CURLOPT_HTTPHEADER, $header); //curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/4.0"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); //This is the result from Textlocal curl_close($ch); if($result === false) { //if(curl_exec($ch) === false) {// echo '<font color=red>Message sending failed</font>'; } else { echo '<font color=green>SMS Message successfully Sent.</font>'; } print($result); ?>



Reply With Quote

Bookmarks