douhan4812 2014-05-23 20:54
浏览 59

PHP发送SMS API

have a look at below snippet inside my PHP code :

function SMS(){

$msg1="".$bookingNo."
".$guestName."
".$guestEmail."
".$guestPhone."
".$guestAddress."
".$place."
".$account."
".$reportingDate."
".$reportingTime."";   
file('http://sms.xxxxxxxxxxxxx.co.in/api/webxxxx.php?workingkey=76565xxxxxx&sender=ILUVU&to=9897xxxxxxx&message='.$msg1.'');}

The problem is this that this http link is sending SMS successfully when run on browser window, with some dummy text in &message=.

But when I am assigning all defined and tested variables inside $msg1 & calling it in same url.

Woosh, it shows NO ERROR & nothing happens, on calling this function. NO SMS.

I wonder where m wrong ?

Thanks

UPDATED CODE :

function SMS(){

$bookingNo=$_REQUEST['bookingNo'];
$guestName=$_REQUEST['guestName'];
$guestEmail=$_REQUEST['guestEmail'];
$guestPhone=$_REQUEST['guestPhone'];
$guestAddress=$_REQUEST['guestAddress'];
$place=$_REQUEST['place'];
$account=$_REQUEST['account'];
$reportingDate=$_REQUEST['reportingDate'];
$reportingTime=$_REQUEST['reportingTime'];

$msg1="".$bookingNo."
".$guestName."
".$guestEmail."
".$guestPhone."
".$guestAddress."
".$place."
".$account."
".$reportingDate."
".$reportingTime."";
file('http://sms.xxxxxxxxxxxxx.co.in/api/webxxxx.php?workingkey=76565xxxxxx&sender=ILUVU&to=9897xxxxxxx&message='.$msg1.'');}



}

SMStoDriver();

  • 写回答

2条回答 默认 最新

  • duanli0119 2014-05-23 20:57
    关注

    It looks like you are trying to use the file method to make the web request. Perhaps your PHP ini is configured to not allow file I/O requests to URLs.

    You would be better off making the web request with something like cURL.

    $curl = curl_init();
    
    curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => 'http://sms.xxxxxxxxxxxxx.co.in/api/webxxxx.php?workingkey=76565xxxxxx&sender=ILUVU&to=9897xxxxxxx&message=test',
        ));
    
    $resp = curl_exec($curl);
    
    curl_close($curl);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog