Curl PHP http_code返回0但浏览器返回200

时间:2018-04-30 10:20:49

标签: php curl

PHP卷曲会发生这种情况。

我的代码看起来像

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.myvaluefirst.com/smpp/sendsms?username=xxxxx&password=xxxx&to=xxxxx&text=Dear&from=STLTD');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_exec($ch);

如果我从浏览器运行URL而不是发送短信并返回http_code 200但是当我使用cURL时它返回http_code 0。

curl_getinfo($ ch)的输出;

Array
(
    [url] => http://www.myvaluefirst.com/smpp/sendsms?username=xxxx&password=xxxx&to=xxx&text=Dear&from=STLTD
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 160
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 20.035848
    [namelookup_time] => 5.019469
    [connect_time] => 5.02008
    [pretransfer_time] => 5.020088
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => 0
    [starttransfer_time] => 20.035834
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

)

0 个答案:

没有答案
相关问题