tags:

views:

440

answers:

6

i couldnt send sms using the following code, but i can sent sms using the same url, while i paste the url($murl) it into browser address bar

connection timed out, takes too much time to execute, but no result

what is the problem?

$amount="500";
$d="23-03-09";

$mNumber="98689988898";
$mName="TEST";
$mMessage ="\"We have debited Rs.$amount. Your account on $d.  Thank you for your valuable support.";
$u1 = 'http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?';
$u2= 'username='.urlencode('some').'&password='. urlencode('some').'&sendername='.urlencode('some') .'&mobileno='
. urlencode($mNumber).'&message='.urlencode($mMessage).'&submit=Submit';

$murl=$u1.$u2;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $murl);
//curl_setopt($ch, CURLOPT_HEADER, 1); 
//curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
/*curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $u2);
*/$response = curl_exec($ch);
print "Respons : $response";
curl_close($ch);
A: 

Change your code to this. Should work:

FROM

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $murl);

TO

$ch = curl_init($murl);

You can set the URL in the curl_init function as well.

jerebear
thank you for your reply but same problem exists, the query execution finished in 2 min, takes too much time, sms server is working fine
A: 

You can also omit curl with $response = file_get_contents($murl) if you don't need server side header answers. Check also http_build_query().

raspi
thank you for your reply, connection timed out, takes too much time to execute, but no result
A: 

Perhaps you need to set a user agent. The service you're using could be blocking the default user agent:

curl_setopt($ch, CURLOPT_USERAGENT, 'SMS Gateway Agent/1.0'); // Pick something creative, or use a browser UA

Hope this helps!

mattbasta
A: 

May i know , u r run php in which OS

Bharanikumar
A: 

hi is there any one giving the free sms gateway...

Bharanikumar
A: 

mysmsmantra is now available as a drupal module you can use the same with triggers and actions the module can be found at http://drupal.org/project/sms_mysmsmantra

Nagar