Oto kodzik wyciągnięty z mojego programiku dla ciebie to jakis szkielecik tego co trzeba zrobić.
Trzeba tak:
1 połączyć się ze stroną i pobrać ją
2 odebrac i zapisać cookie
3 odpowiedzieć wysyając żądany formularz oraz zapisane wcześniej cookie
należy ominąć przy tym ssl :)
void SendFrm::SendPost()
{
wxString f = GetArgv(0) + GetArgv(4);
//static const char *pagefilename = "strona.txt";
static const char *pagefilename = f;
FILE *pagefile;
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl)
{
wxString Proxy = GetArgv(7).mb_str(); // to jest dziwne ale tylko jak tak podwójnie przepisze i zkonwertuje to działa :)
curl_easy_setopt(curl, CURLOPT_PROXY, Proxy.mb_str() );
// Set up a couple initial paramaters that we will not need to mofiy later.
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/4.0");
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1 );
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1 );
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "");
curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1);
// ominiecie CA
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
///
// Visit the login page once to obtain a PHPSESSID cookie
wxString URL = GetArgv(2).mb_str();
curl_easy_setopt(curl, CURLOPT_URL, URL.mb_str() ); //https://www.kinoman.tv/auth/login?return=affilate/points/ https://www.kinoman.tv/auth/login/
curl_easy_perform( curl );
curl_easy_setopt(curl, CURLOPT_PROXY, Proxy.mb_str() ); // ustawiem proxy jeszcze raz tak dla pewnosci
// ominiecie CA
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
///
// Now, can actually login. First we forge the HTTP referer field, or HTS will deny the login
curl_easy_setopt(curl, CURLOPT_REFERER, URL.mb_str() ); // ?return=affilate/points/
// Next we tell LibCurl what HTTP POST data to submit
wxString PostMessage = GetArgv(3).mb_str(); // to jest dziwne ale tylko jak tak podwójnie przepisze i zkonwertuje to działa :)
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, PostMessage.mb_str() );
//curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data_toFile);
pagefile = fopen(pagefilename, "wb"); /* open the file */
if (pagefile)
{
curl_easy_setopt(curl, CURLOPT_FILE, pagefile); // write the page body to this file handle. CURLOPT_FILE is also known as
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
fclose(pagefile);
}
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}