Re: POST fields through CURL

From: Date: Mon, 12 Aug 2002 02:36:16 +0000
Subject: Re: POST fields through CURL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-112087@lists.php.net to get a copy of this message
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'm hoping someone can tell me how the post fields are formatted. I'm looking to pass a string to curl_setopt( $ch, CURLOPT_POSTFIELDS, $string), but the specifications don't tell one HOW to format the string. Is it just like a GET string or what? Anyone know? Thanks, Mike


« previous php.general (#112087) next »