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=NUL L;
char buf[] = "Expect:";
curl_global_ini t(CURL_GLOBAL_A LL);
/* Fill in the file upload field */
curl_formadd(&f ormpost,
&lastptr,
CURLFORM_COPYNA ME, "rajani.vemula" ,
CURLFORM_END);
/* Fill in the filename field */
curl_formadd(&f ormpost,
&lastptr,
CURLFORM_COPYNA ME, "xxxxx",
CURLFORM_END);
curl_formadd(&f ormpost,
&lastptr,
CURLFORM_COPYNA ME, "null",
CURLFORM_COPYCO NTENTS, "Sign in",
CURLFORM_END);
curl = curl_easy_init( );
/* initalize custom header list (stating that Expect: 100-continue
is
not
wanted */
headerlist = curl_slist_appe nd(headerlist, buf);
if(curl) {
/* what URL that receives this POST */
curl_easy_setop t(curl, CURLOPT_URL,"
http://mail.google.com/mail");
curl_easy_setop t(curl, CURLOPT_PROXY, "proxyname" );
curl_easy_setop t(curl, CURLOPT_PROXYUS ERPWD, "User:Password) ";
/* only disable 100-continue header if explicitly requested */
curl_easy_setop t(curl, CURLOPT_HTTPHEA DER, headerlist);
curl_easy_setop t(curl, CURLOPT_HTTPPOS T, formpost);
res = curl_easy_perfo rm(curl);
/* always cleanup */
curl_easy_clean up(curl);
/* then cleanup the formpost chain */
curl_formfree(f ormpost);
curl_slist_free _all(headerlist
}
return 0;
}
Thanks
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=NUL L;
char buf[] = "Expect:";
curl_global_ini t(CURL_GLOBAL_A LL);
/* Fill in the file upload field */
curl_formadd(&f ormpost,
&lastptr,
CURLFORM_COPYNA ME, "rajani.vemula" ,
CURLFORM_END);
/* Fill in the filename field */
curl_formadd(&f ormpost,
&lastptr,
CURLFORM_COPYNA ME, "xxxxx",
CURLFORM_END);
curl_formadd(&f ormpost,
&lastptr,
CURLFORM_COPYNA ME, "null",
CURLFORM_COPYCO NTENTS, "Sign in",
CURLFORM_END);
curl = curl_easy_init( );
/* initalize custom header list (stating that Expect: 100-continue
is
not
wanted */
headerlist = curl_slist_appe nd(headerlist, buf);
if(curl) {
/* what URL that receives this POST */
curl_easy_setop t(curl, CURLOPT_URL,"
http://mail.google.com/mail");
curl_easy_setop t(curl, CURLOPT_PROXY, "proxyname" );
curl_easy_setop t(curl, CURLOPT_PROXYUS ERPWD, "User:Password) ";
/* only disable 100-continue header if explicitly requested */
curl_easy_setop t(curl, CURLOPT_HTTPHEA DER, headerlist);
curl_easy_setop t(curl, CURLOPT_HTTPPOS T, formpost);
res = curl_easy_perfo rm(curl);
/* always cleanup */
curl_easy_clean up(curl);
/* then cleanup the formpost chain */
curl_formfree(f ormpost);
curl_slist_free _all(headerlist
}
return 0;
}
Thanks