curl-library
Re: How to sent username and password using post method
Date: Mon, 14 Jul 2008 14:30:24 -0400
Ajeet kumar.S wrote:
> Hi all,
>
> Thank you //Joe N.//I was trying to implement login using post method
> using curl api but I did not get success. Which is written below?
>
>
>
> Char user_passwd[128];
>
> Strcpy(user_passwd,”username=abc123_at_yahoo.com&password=abc”);
>
> struct curl_slist *xmit_login_header_list = NULL;
>
> xmit_login_header_list =
> curl_slist_append(xmit_login_header_list,"Content-Type:
> application/x-www-form-urlencoded");
>
> curl_easy_setopt(curl , CURLOPT_POST, 1);
>
> curl_easy_setopt(curl, CURLOPT_URL, “http://www.yahoo.com%94);
>
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS,);
>
> curl_easy_perform(curl );
>
>
>
> please suggest me how I can implement the login process using POST
> method using curl api.
>
>
>
> Thank you.
>
> Regards,
>
> Ajeet.
>
Ajeet,
You should probably try this:
char* user_passwd = ”username=abc123_at_yahoo.com&password=abc”;
curl_easy_setopt(curl , CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_URL, “http://www.yahoo.com%94);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, user_passwd);
curl_easy_perform(curl );
You need to make sure everything in user_passwd has been properly
encoded though (I am not sure if '@' will pass).
HTH
Thanks
Wei
Received on 2008-07-14