當前位置:成語大全網 - 書法字典 - 如何使用CHttpConnection發送帖子信息

如何使用CHttpConnection發送帖子信息

CInternetSession m_winet(NULL,1,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);

CHttpConnection * pConnection

CHttpFile * pFile

pConnection = m_winet。GetHttpConnection(" expert . csdn . net ");

CString strHeaders,tempStr,str

str = " name = * * * * * * * & amppass = * * * * * * & amptype = 1 ";

//strHeaders = _ T(" Content-Type:application/x-www-form-urlencoded ");

pFile = p connection-& gt;open request(CHttpConnection::HTTP _ VERB _ POST,

"/member/logon . ASP ");

pFile-& gt;AddRequestHeaders(" Accept:image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,application/vnd.ms-powerpoint,application/vnd.ms-excel,application/msword,*/*);

pFile-& gt;AddRequestHeaders("用戶代理:Mozilla/4.0(兼容;MSIE 5.01;windows NT 5.0)”);

pFile-& gt;AddRequestHeaders(" Content-Type:application/x-www-form-urlencoded ");

pFile-& gt;發送請求(

空,0,

(LPVOID)(LPCTSTR)STR,str。GetLength());

以上是登錄部分,然後用InternetGetCookie獲取Cookie,然後放入AddRequestHeaders,再將請求送出send request(chttpConnection::http _ verb _ post,

"/member/logon . ASP ");chttpconnection::http _ verb _ POST控制的是POST還是GET,所以最好通過攔截數據包來分析。COOKIES需要添加到post中。