curl
Posted: Sat Aug 04, 2007 8:39 am
Hi all
I have function to send SMS to gateway, that shoul "pick" another gateway if first gateway failed.
here is function
Now if first sending of sms (priority 1) failed, function should pick second and etc.
and that works fine.
Problem is that I don't get response in variable $response (for priority 2 - if first failed), even if curl_exec($ch) has been executed (I do get sms).
This is not working only for priority 2. Priority 1 works well.
I don't get it. Code is the same !?!?!?!?
Please if somebody could help me. I'm stacked.
kind regards
ddragas
I have function to send SMS to gateway, that shoul "pick" another gateway if first gateway failed.
here is function
Code: Select all
<?
function sendSMS($gsm, $message, $priority, $uniqueID)
{
$end = 3;
if($priority == $end){exit();}
if (empty($priority)){$priority = 1;}
if($priority==2)
{
$url_za_sms = "http://newurltosendsms.com";
$url_za_sms .="?number=" . $gsm ;
$url_za_sms .= "&message=" . urlencode($message);
$url_za_sms .= "&type=LongSMS";
$url_za_sms .= "&mess_id=" . $uniqueID;
$url_za_sms .= "&delivery=1";
$ch = curl_init($url_za_sms);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = trim(curl_exec($ch));
if(!is_numeric($response))
{
$priority++;
sendSMS($gsm, $poruka, $priority, $uniqueID);
}
else
{
return $response;
}
}
if($priority==1)
{
$url_za_sms = "http://someurltosendsms.com";
$url_za_sms .="?number=" . $gsm ;
$url_za_sms .= "&message=" . urlencode($message);
$url_za_sms .= "&type=LongSMS";
$url_za_sms .= "&mess_id=" . $uniqueID;
$url_za_sms .= "&delivery=1";
$ch = curl_init($url_za_sms);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = trim(curl_exec($ch));
if($response != "success")
{
$priority++;
sendSMS($gsm, $poruka, $priority, $uniqueID);
}
else
{
return $response;
}
}
}
?>and that works fine.
Problem is that I don't get response in variable $response (for priority 2 - if first failed), even if curl_exec($ch) has been executed (I do get sms).
This is not working only for priority 2. Priority 1 works well.
I don't get it. Code is the same !?!?!?!?
Please if somebody could help me. I'm stacked.
kind regards
ddragas