cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Plz help me posting data to a url

From: Ralph Mitchell <ralphmitchell_at_gmail.com>
Date: Wed, 8 Jun 2005 02:08:40 -0500

On 6/8/05, Daniel Stenberg <daniel-curl_at_haxx.se> wrote:
> On Wed, 8 Jun 2005, kl rao wrote:
>
> > curl_easy_setopt(curls,
> > CURLOPT_POSTFIELDS,mob);
> > curl_easy_setopt(curls,
> > CURLOPT_POSTFIELDS,txt);
>
> The second call will override what you set in the previous one. You can only
> set one CURLOPT_POSTFIELDS.

Also, you haven't set any POST variables. When you do this:

   strcpy(txt,"this is test");

the equivalent curl command line would look like this:

     curl -d "this is test" http://.........

Now, if you to do this instead:

     strcpy(txt,"txt=this is test");

that would be the same as:

     curl -d txt="this is a test" http://......

and the server would be given a POST variable called txt with the
specified content. And you should encode the spaces too:

     strcpy (txt, "txt=this%20is%20a%20%20text&mob=919849339091");

assuming "txt" and "mob" are the variable names that the server is expecting.

Ralph Mitchell
Received on 2005-06-08