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?