Log in to Google using libcurl in C

I am trying to login to google using the libcurl library in C. But google answers me: "The functionality of your browser browser is disabled. Please enable it."

Here is the code:

#include <stdio.h> #include <stdlib.h> #include <curl/curl.h> size_t get_buffer(void *buffer, size_t size, size_t nmemb, void *userp); int main(void) { CURL *curl; CURLcode res; char *data="service=...&dsh=...&GALX=...&pstMsg=0&dnCon=&checkConnection=&Email=...&Passwd=..."; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://accounts.google.com/ServiceLoginAuth"); curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookie"); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookie"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, get_buffer); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } return 0; } 

Any idea? Thanks.

+4
source share
1 answer

You need to call the webpage twice to receive a cookie. Please look:

http://www.hackthissite.org/articles/read/1078

There is your answer @ "Getting a web page (using cookies!):"

+2
source

Source: https://habr.com/ru/post/1394245/


All Articles