如题,我在linux里使用libcurl模拟邮件系统登录,为什么一直都登录不进去呢?
返回的页面Body能看到提示,帐号或密码错误!!!
CURL* curl = curl_easy_init();
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, headerData);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, “username=wang123&password=123456&language=zh_CN&enter=true”);
curl_easy_setopt(curl,CURLOPT_COOKIEFILE,"/tmp/cookie.txt");
curl_easy_setopt(curl,CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
curl_easy_setopt(curl, CURLOPT_URL, “http://mail.***.com.cn:8001/webmail/index.php?module=operate&action=login”);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_easy_perform(curl);
我使用curl就可以./curl --data "username=wang&password=123456&language=zh_CN&enter=true" -X POST "http://mail.***.com.cn:8001/webmail/index.php?module=operate&action=login"
用tcpdoump抓包后看到POST数据是正确发出了的