1,增加HTTP Header
curl_slist *plist = curl_slist_append(NULL, “Client-Key:m-5be02cd9ddfb11dcaf9700142218fc6e”);
curl_slist_append(plist, “username:winter_445@163.com”);
curl_slist_append(plist, “password:123456”);
curlRet = curl_easy_setopt(m_hCURL, CURLOPT_HTTPHEADER, plist);
这样即可在HTTP Header中加入上面的内容。
2,增加Post Form的数据
curlRet = curl_easy_setopt(m_hCURL,CURLOPT_POSTFIELDS, “Client-Key=m-5be02cd9ddfb11dcaf9700142218fc6e&username=winter_445@163.com&password=123456”);
像上面那样,可以在Post表单中加上任意数据。
3,让CURL记录Cookie
curlRet = curl_easy_setopt(m_hCURL, CURLOPT_COOKIEFILE, “”);
curlRet = curl_easy_setopt(m_hCURL, CURLOPT_COOKIEJAR, “”);
像上面那样设置一下,试验中发现不需要指定cookie文件名它也能工作