cURL - 错误请求(无效号码)

发布于 2024-10-14 12:05:06 字数 1644 浏览 2 评论 0原文

我在我的系统上设置了一个小型 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗫嚅 2024-10-21 12:05:06

删除 CURLOPT_POST 选项解决了该问题。然而,它并没有在我的本地电脑上造成任何问题。

Removing the CURLOPT_POST option resolved the issue. It wasn't however creating any problem on my local PC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文