cURL - 错误请求(无效号码)
我在我的系统上设置了一个小型 PHP 脚本(运行 XAMPP),它工作得很好,但是当我将其上传到我的网络服务器时,它显示:错误请求(无效数字)。可能是什么原因?
这是我的代码:
$url = "http://domain.com/filename.aspx?client=saad%40domain.com&oper=d&gname=g1";
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)",
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 120,
CURLOPT_TIMEOUT => 120,
CURLOPT_MAXREDIRS => 10,
CURLOPT_POST => true,
);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
$header = curl_getinfo($ch);
curl_close($ch);
print_r($header);
echo $content;
标题数组显示:
Array
(
[url] => http://domain.com/filename.aspx?client=saad%40domain.com&oper=d&gname=g1
[content_type] => text/html
[http_code] => 400
[header_size] => 129
[request_size] => 337
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.034575
[namelookup_time] => 0.029746
[connect_time] => 0.030606
[pretransfer_time] => 0.030615
[size_upload] => 0
[size_download] => 37
[speed_download] => 1070
[speed_upload] => 0
[download_content_length] => 37
[upload_content_length] => -1
[starttransfer_time] => 0.03455
[redirect_time] => 0
)
提前致谢!
I have set up a small PHP script on my system (running XAMPP) and it is working perfectly fine but when I upload it to my web server it says: Bad Request (Invalid Number). What may be the reason?
Here is my code:
$url = "http://domain.com/filename.aspx?client=saad%40domain.com&oper=d&gname=g1";
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)",
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 120,
CURLOPT_TIMEOUT => 120,
CURLOPT_MAXREDIRS => 10,
CURLOPT_POST => true,
);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
$header = curl_getinfo($ch);
curl_close($ch);
print_r($header);
echo $content;
And the header array shows:
Array
(
[url] => http://domain.com/filename.aspx?client=saad%40domain.com&oper=d&gname=g1
[content_type] => text/html
[http_code] => 400
[header_size] => 129
[request_size] => 337
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.034575
[namelookup_time] => 0.029746
[connect_time] => 0.030606
[pretransfer_time] => 0.030615
[size_upload] => 0
[size_download] => 37
[speed_download] => 1070
[speed_upload] => 0
[download_content_length] => 37
[upload_content_length] => -1
[starttransfer_time] => 0.03455
[redirect_time] => 0
)
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除 CURLOPT_POST 选项解决了该问题。然而,它并没有在我的本地电脑上造成任何问题。
Removing the CURLOPT_POST option resolved the issue. It wasn't however creating any problem on my local PC.