Re: Re: POST fields through CURL
| From: | Bogdan Stancescu | Date: | Mon, 12 Aug 2002 03:25:45 +0000 |
| Subject: | Re: Re: POST fields through CURL | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112092@lists.php.net to get a copy of this message | ||
Duh, yes, of course, I'm stupid - I forgot you were talking about Curl - I never used it so it may be the way you say it is. The piece of code I sent you was a part of what I used to build a full HTTP request (connecting to the server and sending it - everything done by hand), and Curl may be building the header instead.
Curl *should* typically get the string preparsed though, so I may not be completely off with the code - but then again, I can't be certain.
Sorry for the mishap!
Bogdan
Jonathan Rosenberg wrote:
Are you sure that the HTTP header should be on there? I don't believe that is correct. It is the use of CURLOPT_POSTFIELDS with the curl_setopt function that indicates that a POST is being made. I just checked the code I used for credit card clearing & it does NOT include the HTTP headers. Just the POST data.-----Original Message----- From: Bogdan Stancescu [mailto:mgv@canad.ro] Sent: Sunday, August 11, 2002 22:36 PM To: php-general@lists.php.net Subject: [PHP] Re: POST fields through CURL Yes, the strings are formatted exactly like GET strings, but you'll have to build the whole HTTP header in front of them in order to get a valid HTTP request. So then, your code should look something like $myvar1=rawurlencode($myvar1); $myvar2=rawurlencode($myvar2); $parsed="myvar1=$myvar1&myvar2=$myvar2"; $len=strlen($parsed) $request="POST $request_path HTTP/1.0\r\n"."Content-Type: application/x-www-form-urlencoded\r\n". "User-Agent: My PHP application v1.0\r\n". "Host: $host\r\n". "Content-Length: $len\r\n". "Connection: Keep-Alive\r\n". "\r\n". // This separates the header from the content $parsed;After that, you send $request. Bogdan Mike Mannakee wrote:Hi all, I'm setting up a curl operation with post fields, and I'mhoping someone cantell me how the post fields are formatted. I'm looking to passa string tocurl_setopt( $ch, CURLOPT_POSTFIELDS, $string), but thespecifications don'ttell one HOW to format the string. Is it just like a GETstring or what?Anyone know? Thanks, Mike-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php