【发布时间】:2023-03-25 21:19:01
【问题描述】:
我想从我的网站发送短信。 php 代码在本地主机上运行良好,但没有从 Web 服务器获得任何响应。我是否错过了在 Web 服务器中配置某些内容?请帮我.. 这是下面给出的代码...
<?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";}
*/
?>
修改代码
<?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";}
*/
?>
显示页面
<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>
【问题讨论】:
-
这次好多了!
-
var_dump(curl_getinfo($ch));在执行之后但在关闭之前。应该给你一些提示。由于此代码在这里有效,但当然只显示如下内容:“请求的资源不可用”。
-
@Julian Hille 谢谢...至少没有得到空白页...但问题尚未解决。我已经发布了我的问题的结果。
标签: php sms httprequest sms-gateway