问题描述
我正在尝试使用一个名为SMSGateway的sms网关应用程序,使用curl进行http标头请求,如下所示;
$ curl_handle = curl_init();
curl_setopt($ curl_handle,CURLOPT_URL,http://182.70.76.188:9090/sendsms?phone=$phone&text=$message1&password=xxxxxxxx);
curl_setopt($ curl_handle,CURLOPT_CONNECTTIMEOUT,10000);
curl_setopt($ curl_handle,CURLOPT_TIMEOUT,50000);
curl_setopt($ curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ curl_handle,CURLOPT_USERAGENT,'Mozilla / 5.0(Windows NT 6.1; rv:36.0)Gecko / 20100101 Firefox / 36.0');
$ query = curl_exec($ curl_handle) ;
if($ query){echo消息发送到$ phone!
;} else {echo消息未发送到$ phone!
; echo'卷曲错误: '。 curl_error($ curl_handle)。
;}
curl_close($ curl_handle);
这在我的本地工作得很好系统,但从服务器执行时它会超时...
我需要知道什么是错的...它是卷曲问题吗?我应该使用file_get_contents吗?其实我确实尝试过file_get_contents ...也没用。
I am trying to use a sms gateway app for android called SMSGateway with a http header request using curl as below;
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,"http://182.70.76.188:9090/sendsms?phone=$phone&text=$message1&password=xxxxxxxx");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 10000);
curl_setopt($curl_handle, CURLOPT_TIMEOUT,50000);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:36.0) Gecko/20100101 Firefox/36.0');
$query = curl_exec($curl_handle);
if($query){echo "Message Sent to $phone !
";}else{echo "Message Not Sent to $phone !
";echo 'Curl error: ' . curl_error($curl_handle)."
";}
curl_close($curl_handle);
This works perfectly fine on my local system but it gets timed out when executing from server...
I need to know what is wrong...is it a curl issue ? should i use file_get_contents ? Actually I did try file_get_contents...did not work too..
这篇关于http标头请求未从远程服务器连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!