0

I want to send SMS from my website. The php code is working fine from localhost but not getting any response from web server. Have I missed to configure something in web server? Please help me.. Here is the code given below...

<?php

$ch = curl_init("http://priority.muzztech.co.in:8080/sms?");
curl_setopt($ch, CURLOPT_POSTFIELDS,"username=username&password=password&type=0&dlr=1&destination=+91xxxxxxxxxx&source=XXXXXX&message=test");
curl_setopt($ch, CURLOPT_TIMEOUT,60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);

$contents = curl_exec ($ch);
curl_close ($ch);

Print($contents);

/*if(stristr($contents,"Message Submitted")){
$mstatus="SMS send Sucessfully ";}
else {
$mstatus="SMS send Failed";} 
*/

?>

Edited the code to

<?php

$ch = curl_init("http://priority.muzztech.co.in:8080/sms?");

curl_setopt($ch, CURLOPT_POST, True);
curl_setopt($ch, CURLOPT_POSTFIELDS,"uusername=username&password=password&type=0&dlr=1&destination=+91xxxxxxxxxx&source=XXXXXX&message=test");
curl_setopt($ch, CURLOPT_TIMEOUT,60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);

$contents = curl_exec ($ch);

var_dump(curl_getinfo($ch));

curl_close ($ch);
Print($contents);
/*if(stristr($contents,"Message Submitted")){
$mstatus="SMS send Sucessfully ";}
else {
$mstatus="SMS send Failed";} 
*/

?>

the page showing

<pre>array(20) { 
["url"]=> string(40) "http://priority.muzztech.co.in:8080/sms?" 
["content_type"]=> NULL 
["http_code"]=> int(0) 
["header_size"]=> int(0) 
["request_size"]=> int(0) 
["filetime"]=> int(-1) 
["ssl_verify_result"]=> int(0) 
["redirect_count"]=> int(0) ["total_time"]=> float(21.226878) 
["namelookup_time"]=> float(0.22723) 
["connect_time"]=> float(0) 
["pretransfer_time"]=> float(0) 
["size_upload"]=> float(0) 
["size_download"]=> float(0) 
["speed_download"]=> float(0) 
["speed_upload"]=> float(0)
["download_content_length"]=> float(-1)
["upload_content_length"]=> float(-1)
["starttransfer_time"]=> float(0) 
["redirect_time"]=> float(0) }</pre>
Subha
  • 1
  • 2
  • Much better this time! – L0j1k Feb 23 '13 at 11:30
  • var_dump(curl_getinfo($ch)); AFTER the exec but before close. Should give you some hints. As this code works here, but of course only displays something like: "Requested Resource not available". – Julian Hille Feb 23 '13 at 12:09
  • @ Julian Hille thanks... at least not getting a blank page... but the problem has not been resolved yet. I have posted the result with my question. – Subha Feb 23 '13 at 17:22

3 Answers3

0

When doing the CURL HTTP post you need to specify CURLOPT_POST, true before CURLOPT_POSTFIELDS, ..., because CURL's default http method is GET.

Miloš Đakonović
  • 3,751
  • 5
  • 35
  • 55
0

I have also faced the same problem and tried to solve the problem using a whole day. Everything was working well in my local-host but when I placed this in web server nothing work here.

I used the above code with a little change and now it is working for me. I have tried to solve this problem with a lots of combination. Surprisingly, I saw that when I use port number 8080 nothing work here. But when I eliminated the port number and try to send my SMS again, it is working. I also changed 'uusername' as 'username' from the above code.

Finally my Code is:

<?php

$ch = curl_init("http://priority.muzztech.co.in/sms?");

curl_setopt($ch, CURLOPT_POST, True);
curl_setopt($ch, CURLOPT_POSTFIELDS,"username=username&password=password&type=0&dlr=1&destination=8801XXXXXXXXX&source=XXXXXX&message=test");
//8801XXXXXXXXX mobile number format for Bangladesh
curl_setopt($ch, CURLOPT_TIMEOUT,60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);

$contents = curl_exec ($ch);

curl_close ($ch);

?>
0
**In my case below code worked successfully** 

$abc= 'http://bullet1.sdctechnologies.co.in:8080/api/mt/SendSMS?user='.$sms_username.'&password='.$sms_password.'&senderid='.$sms_sender_id.'&channel=Trans&DCS=0&flashsms=0&number='.$txt_mobile.'&text='.$message.'';

 $url = str_replace(" ","%20",$abc);
            $ch = curl_init();
            curl_setopt($ch,CURLOPT_URL,$url); 
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
            $response = curl_exec($ch);
            curl_close($ch);
sandeep autade
  • 261
  • 7
  • 17