【问题标题】:Error 413 when using curl to post使用 curl 发帖时出现错误 413
【发布时间】:2010-12-27 20:36:12
【问题描述】:

每次我尝试使用 curl 使用 php 脚本发布数据时都会收到错误 413。 我可以“获取”网页,但是当我使用“发布”时,脚本会随着

does not allow request data with POST requests, or the amount of data provided<br> in the request exceeds the capacity limit.

我有一个 py 脚本,它可以工作。 这是一个不起作用的示例代码:





 $q=curl_init(POSTURL);

 curl_setopt($q,CURLOPT_POST,true);
 curl_setopt($q,CURLOPT_RETURNTRANSFER,true);


 $post=array("q"=>2);
   $ss=curl_setopt($q,CURLOPT_URL,"http://localhost");
        curl_setopt($q,CURL_POSTFIELDS,$post);
 $f=curl_exec($q);
 curl_close($q);
        echo $f." is error"; 

我不知道问题出在 apache 上,还是我的脚本上还是其他问题。

【问题讨论】:

    标签: php post curl get


    【解决方案1】:

    网络服务器是否已配置为允许 POST?在 Apache 上,这很可能是 &lt;Limit&gt; 指令。或者LimitRequestBody 是否已设置为 0(或至少比您的帖子的值更小)?

    【讨论】:

    • no. 即使脚本不在服务器上(例如在 /usr/ 中),脚本也不起作用
    • 无论你的 curl 脚本在哪里,我的意思是要发布到的脚本。您收到服务器端错误响应,这意味着问题出在 Web 服务器和/或您尝试与之通信的脚本上。
    • 但是每个 url 地址都会发生这种情况,不仅仅是我服务器上的那些。示例不适用于“example.com”,python 脚本有效。
    • 那么你的 PHP 和/或 curl 配置有问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    相关资源
    最近更新 更多