dongsuikai8286 2014-03-14 12:23 采纳率: 100%
浏览 75

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

So I have a script to manage game options and it worked quite well a few weeks ago. However, game server changed and my script can't handle POST requests through cURL anymore.

This works fine:

$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);

I get desired output. However, the code that goes right after it:

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);

gives me this result:

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 request failed. Game sends back the message about an uknown error and I noticed that headers show that Content-Length is... 0.

All variables are correct, I debugged it.

I just don't know how to handle that. How to make POST requests available again.

PS: The thing is, only THIS module is screwed up with POST requests. I can still send automated messages in game (it's using cURL POST as well). Why this particular returns Content-Length: 0?

PS2: Yes, I tried to include

curl_setopt($curl, CURLOPT_POST, 1);

and nothing happened.

Help, anybody?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 fluent的在模拟压强时使用希望得到一些建议
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用
    • ¥15 Web.config连不上数据库
    • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
    • ¥15 怎么配置广告联盟瀑布流
    • ¥15 Rstudio 保存代码闪退