curl-library
posting and cookies problem on windows
Date: Tue, 21 Aug 2001 11:33:49 +0100
whats wrong with the following snippet of code? I want it to post to a form
(login), save the header (so I capture the cookie), and them post to another
url which requires the cookie from the first form.
I am doing this under windows, if that helps.
curl_formparse("username=AName",
&formpost,
&lastptr);
curl_formparse("password=APassword",
&formpost,
&lastptr);
curl = curl_easy_init();
if(curl) {
/* what call to write: */
printf("Setting up easy optins\n");
curl_easy_setopt(curl, CURLOPT_URL, "http://aurl/");
curl_easy_setopt(curl, CURLOPT_VERBOSE);
curl_easy_setopt(curl, CURLOPT_HEADER);
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
res = curl_easy_perform(curl);
/* always cleanup */
curl_formfree(formpost);
}
formpost = NULL;
lastptr = NULL;
curl_formparse("RECIPIENT=01234567891",
&formpost,
&lastptr);
curl_formparse("SUBJECT=TESTMESSAGE",
&formpost,
&lastptr);
curl_formparse("TEXT=FROMTHEWEB",
&formpost,
&lastptr);
curl_formparse("action=Send",
&formpost,
&lastptr);
curl_formparse("check=0",
&formpost,
&lastptr);
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://anewurl/");
curl_easy_setopt(curl, CURLOPT_VERBOSE);
curl_easy_setopt(curl, CURLOPT_HEADER);
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "header");
curl_easy_setopt(curl, CURLOPT_REFERER, "http://anewurl/");
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
curl_formfree(formpost);
}
Received on 2001-08-21