I have an PHP class which is used to POST some data to a server, and GET some data back using the same open connection. The problem is that this code will try to POST data from 1st request, in the 2nd request...
curl_setopt(self::$ecurl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt(self::$ecurl, CURLOPT_POSTFIELDS, $data);
$request=curl_exec(self::$ecurl);
curl_setopt(self::$ecurl, CURLOPT_CUSTOMREQUEST, "GET");
$request=curl_exec(self::$ecurl);
So i need the way to unset CURLOPT_POSTFIELDS
. I tried to use curl_setopt(self::$ecurl, CURLOPT_POSTFIELDS, null);
, but anyway curl send Posting 0 bytes...
in request's header.
Also please note, that i need to use exactly the same connection, so I can't create another connection via curl_init.
Set the CURLOPT_HTTPGET
to true
prior to the last request.
From PHP.net:
CURLOPT_HTTPGET
TRUE to reset the HTTP request method to GET. Since GET is the default, this is only necessary if the request method has been changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With