私は問題があります。 ログインしたいと思っています。 ogameでURLソースコードを読んでください。 しかし、私は自分のコードを開始するたびに、私のファイルは、ログイン後に2番目のページではなく、ログインページを返します。ページにログインしてURLコンテンツを読むにはどうすればいいですか?
#include <stdio.h>
#include <curl/curl.h>
FILE *fptr;
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
fptr = fopen("ogametest.html", "w");
fputs((const char*)contents, (FILE*)fptr);
fclose (fptr);
//printf("%s", (char *) contents);
return size * nmemb;
}
int main(int argc, char **argv){
CURL *curl;
CURLcode res;
char strlist[16000]="";
char* str= &strlist[0];
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://de.ogame.gameforge.com/");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "usernameLogin=myLogin&passwordLogin=myPassw&serverLogin=s146-de.ogame.gameforge.com");
res = curl_easy_perform(curl);
//curl_easy_reset(curl);
curl_easy_setopt(curl, CURLOPT_URL, "https://s146-de.ogame.gameforge.com/game/index.php?page=overview&relogin=1");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, str);
res = curl_easy_perform(curl);
fptr = fopen("ogametest.html", "r");
fgets(str, 16000, fptr);
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();
return 0;
}
私を助けることができればうれしいです。
おはようございます