Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Post data to http server using libcurl

Reply
Thread Tools

Post data to http server using libcurl

 
 
Raj
Guest
Posts: n/a
 
      11-09-2006
Hi,
I am newbie to programming with libcurl. the problem is i want to send
my gmail username and password outside the browser and get access to my
mail. this i am doing with LibCurl. Though i dont get any errors, i am
nt able to get the o/p Can anyone kindly help. i will attach the
program here
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

int main(int argc, char *argv[])
{
CURL *curl;
CURLcode res;

struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
struct curl_slist *headerlist=NULL;
char buf[] = "Expect:";

curl_global_init(CURL_GLOBAL_ALL);

/* Fill in the file upload field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "rajani.vemula",
CURLFORM_END);

/* Fill in the filename field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "xxxxx",
CURLFORM_END);
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "null",
CURLFORM_COPYCONTENTS, "Sign in",
CURLFORM_END);




curl = curl_easy_init();
/* initalize custom header list (stating that Expect: 100-continue
is
not
wanted */
headerlist = curl_slist_append(headerlist, buf);
if(curl) {
/* what URL that receives this POST */
curl_easy_setopt(curl, CURLOPT_URL,"
http://mail.google.com/mail");
curl_easy_setopt(curl, CURLOPT_PROXY, "proxyname");
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "Userassword)";
/* only disable 100-continue header if explicitly requested */
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
res = curl_easy_perform(curl);

/* always cleanup */
curl_easy_cleanup(curl);

/* then cleanup the formpost chain */
curl_formfree(formpost);
curl_slist_free_all(headerlist
}
return 0;
}

Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP SOAP/HTTP GET/HTTP POST milan_9211 Software 0 01-10-2011 02:10 PM
Help Using LibCurl clarkocb@gmail.com Ruby 1 09-08-2008 03:32 PM
telnet from c application using libcurl ?? Jake C Programming 3 02-24-2008 02:38 AM
Post data using the libcurl Raj Python 0 11-09-2006 12:06 PM
Post data using the libcurl Raj Python 0 11-09-2006 12:06 PM



Advertisments