服务器更改后失败的cURL POST请求

时间:2014-03-14 12:23:01

标签: php curl header

所以我有一个脚本来管理游戏选项,几周前它运行得很好。但是,游戏服务器已更改,我的脚本无法通过cURL处理POST请求。

这很好用:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://secura.e-sim.org/donateProducts.html?id=".$player);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_ENCODING, "");
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_COOKIEJAR, $_SERVER["DOCUMENT_ROOT"].'/vdod/cookies/'.$_SESSION["operator"].'.txt');
curl_setopt($curl, CURLOPT_COOKIEFILE, $_SERVER["DOCUMENT_ROOT"].'/vdod/cookies/'.$_SESSION["operator"].'.txt');
curl_exec($curl);

我得到了理想的输出。但是,紧随其后的代码:

curl_setopt($curl, CURLOPT_URL, "http://secura.e-sim.org/donateProducts.html?id=".$player);
curl_setopt($curl, CURLOPT_POSTFIELDS, "product=".$fetchSupplies["gift_quality"]."-GIFT&quantity=".$fetchSupplies["gift_amount"]);
curl_exec($curl);

给了我这个结果:

HTTP/1.1 302 Found Date: Fri, 14 Mar 2014 12:19:41 GMT Server: Apache/2.4.6 (Ubuntu) Location: http://secura.e-sim.org?citizenMessage=UNKNOWN_ERROR Content-Language: en-US Content-Length: 0 Connection: close Content-Type: text/html HTTP/1.1 200 OK Date: Fri, 14 Mar 2014 12:19:41 GMT Server: Apache/2.4.6 (Ubuntu) Content-Language: en-US Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 22927 Connection: close Content-Type: text/html;charset=UTF-8

POST请求失败。游戏发回有关未知错误的消息,我注意到标题显示Content-Length为... 0。

所有变量都是正确的,我调试了它。

我只是不知道如何处理。如何再次提供POST请求。

PS:事情是,只有这个模块搞砸了POST请求。我仍然可以在游戏中发送自动消息(它也使用cURL POST)。为什么这个特殊的东西返回Content-Length:0?

PS2:是的,我试图加入

curl_setopt($curl, CURLOPT_POST, 1);

并没有发生任何事情。

帮助,任何人?

0 个答案:

没有答案