Post data using the libcurl

Discussion in 'Python' started by Raj, Nov 9, 2006.

  1. Raj

    Raj Guest

    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, "User:password)";
    /* 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
     
    Raj, Nov 9, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sylvain/11XX

    libcurl and expat

    Sylvain/11XX, May 23, 2006, in forum: XML
    Replies:
    1
    Views:
    581
    Joe Kesselman
    May 23, 2006
  2. Raj

    Post data using the libcurl

    Raj, Nov 9, 2006, in forum: Python
    Replies:
    0
    Views:
    346
  3. Raj
    Replies:
    0
    Views:
    1,171
  4. Jake
    Replies:
    3
    Views:
    772
    Richard
    Feb 24, 2008
  5. Help Using LibCurl

    , Sep 4, 2008, in forum: Ruby
    Replies:
    1
    Views:
    186
    Mark Thomas
    Sep 8, 2008
Loading...

Share This Page