Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP发送SMS API_Php_Sql_Curl_Sms - Fatal编程技术网

PHP发送SMS API

PHP发送SMS API,php,sql,curl,sms,Php,Sql,Curl,Sms,请看我的PHP代码中的以下代码片段: function SMS(){ $msg1="".$bookingNo."\n".$guestName."\n".$guestEmail."\n".$guestPhone."\n".$guestAddress."\n".$place."\n".$account."\n".$reportingDate."\n".$reportingTime.""; file('http://sms.xxxxxxxxxxxxx.co.in/api/webxxxx.php

请看我的PHP代码中的以下代码片段:

function SMS(){

$msg1="".$bookingNo."\n".$guestName."\n".$guestEmail."\n".$guestPhone."\n".$guestAddress."\n".$place."\n".$account."\n".$reportingDate."\n".$reportingTime."";   
file('http://sms.xxxxxxxxxxxxx.co.in/api/webxxxx.php?workingkey=76565xxxxxx&sender=ILUVU&to=9897xxxxxxx&message='.$msg1.'');}
问题是此http链接在浏览器窗口上运行时成功发送SMS, 在
&message=
中使用一些虚拟文本

但是当我在
$msg1
中分配所有定义和测试的变量时,在同一个url中调用它

哇,调用这个函数时没有显示错误&什么也没有发生。没有短信

我不知道我错在哪里

谢谢

更新代码:

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."\n".$guestName."\n".$guestEmail."\n".$guestPhone."\n".$guestAddress."\n".$place."\n".$account."\n".$reportingDate."\n".$reportingTime."";
file('http://sms.xxxxxxxxxxxxx.co.in/api/webxxxx.php?workingkey=76565xxxxxx&sender=ILUVU&to=9897xxxxxxx&message='.$msg1.'');}



}

SMStoDriver()

看起来您正试图使用
文件
方法发出web请求。也许您的PHPINI配置为

您最好使用以下内容进行web请求


URL中不允许使用换行符。您需要对消息进行编码:

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=urlencode("Booking No: $bookingNo\nName: $guestName\n Email: $guestEmail\nPhone: $guestPhone\nAddress: $guestAddress\nPlace: $place\nAccount: $account\nDate: $reportingDate\nTime: $reportingTime");
    file('http://sms.xxxxxxxxxxxxx.co.in/api/webxxxx.php?workingkey=76565xxxxxx&sender=ILUVU&to=9897xxxxxxx&message='.$msg1.'');}
}

试着释放你的帽子锁。谢谢Barmar。但我的问题是,我的查询向我发送短信,但它只包含很少的空行。你的密码没有给我短信。This-message='.urlencode($msg1));使用-.urlencode($msg1)向我发送短信。Plz帮助如何在我的短信中获取解码值。提前感谢。您在哪里设置所有变量
$bookingNo
$guestName
等。?如果它们设置在函数外部,则必须将它们作为参数传递,或使用
全局
声明才能访问外部变量。确定。我现在将所有使用的变量都设置为局部变量,在这个函数中声明/赋值。现在如何使用.urlencode?但是使用解码消息获取SMS?SMS.xxx.co.in服务器应自动解码URL。这只是URL参数标准语法的一部分。如果仍然不起作用,请在问题中添加一个显示当前代码的更新。
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=urlencode("Booking No: $bookingNo\nName: $guestName\n Email: $guestEmail\nPhone: $guestPhone\nAddress: $guestAddress\nPlace: $place\nAccount: $account\nDate: $reportingDate\nTime: $reportingTime");
    file('http://sms.xxxxxxxxxxxxx.co.in/api/webxxxx.php?workingkey=76565xxxxxx&sender=ILUVU&to=9897xxxxxxx&message='.$msg1.'');}
}