curl-and-php
Re: Postfields question
Date: Mon, 3 Mar 2003 06:38:47 +0100 (CET)
On Sun, 2 Mar 2003, Jesse Brede wrote:
> What is the proper way to use the Postfields function from curl in php?
>
> I have read that $POSTFIELDS needs to be an associative array. This has
> not worked for me.
> Such as
> $POSTFIELDS = array ( "login" => "login_name", "password" => "xxxxxx",
> "header" => "HF#%&=1324WER");
I think that makes the post a multipart one, and not a regular one. They're
not simply interchangable.
> Putting my post variables in one long string seems to be the only way to
> get this function to work correctly.
> such as
> $POSTFIELDS = "login=login_name&password=xxxxx&header=HF#%&=1324WER";
That's the way to do it, yes.
> This being said, I have post variables that oddly enough have both & and =
> symbols in them. Is there a php or curl function to make these variables
> function correctly. I think if I could get the associative array working
> everything would be fine. I have tried using single and double quotes.
You need to "url encode" the strings (before you concatenate them). All such
letters should be replaced with the url version. '&' for example I believe is
%26, etc.
I assume there's a function in PHP that does this for you.
-- Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sfReceived on 2003-03-03