18,356
社区成员
发帖
与我相关
我的任务
分享
CHttpConnection *pConnection;
INTERNET_PORT nPort; //端口
nPort=80;
CString headers,cookies;
CString str=L"r=%7B%22ptwebqq%22%3A%22";//52166f079078f48f4f022538ecc716112a11687c36fa557b12dba34dbac2403d//L"r={\"ptwebqq\":\"";
str+=ptwebqq;
str+=L"%22%2C%22clientid%22%3A53999199%2C%22psessionid%22%3A%22%22%2C%22status%22%3A%22online%22%7D";
//str+=L"\",\"clientid\":53999199,\"psessionid\":\"\",\"status\":\"online\"}";
pConnection=mysession.GetHttpConnection(L"d.web2.qq.com",nPort);
myfile=pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,L"/channel/login2",NULL,
1,
NULL,
NULL,
INTERNET_FLAG_NO_COOKIES );
//headers=L"Content-Type:application/x-www-form-urlencoded; charset=UTF-8";
myfile->AddRequestHeaders(L"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
myfile->AddRequestHeaders(L"Accept-Encoding:gzip, deflate");
myfile->AddRequestHeaders(L"Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3");
myfile->AddRequestHeaders(L"Cache-Control:no-cache");
myfile->AddRequestHeaders(L"Connection:keep-alive");
myfile->AddRequestHeaders(L"Content-Length:180");
myfile->AddRequestHeaders(L"Content-Type:application/x-www-form-urlencoded; charset=UTF-8");
cookies=L"Cookie:skey=";
cookies+=skey;
cookies+=L";";
cookies+=m_edit;
myfile->AddRequestHeaders(cookies);
myfile->AddRequestHeaders(L"Host:d.web2.qq.com");
myfile->AddRequestHeaders(L"Pragma:no-cache");
myfile->AddRequestHeaders(L"Referer:http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2");
myfile->AddRequestHeaders(L"User-Agent:Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0");
myfile->SendRequest(NULL,0,(LPVOID)(LPCTSTR)str, str.GetLength());//运行到这里就会等很久,然后就运行不下去了,可能是超时了吧
//httpname=L"http://d.web2.qq.com/channel/login2";
DWORD len=255;
myfile->QueryInfo(HTTP_QUERY_SET_COOKIE ,m_edit.GetBuffer(255),&len,NULL);
//myfile->SendRequestEx(str.GetLength());
//myfile->WriteString(str);
//myfile->EndRequest();
m_edit=L"";
if(myfile!=NULL)
{
while(myfile->ReadString(tmp))
{
m_edit+=tmp;
}
}
delete myfile;
delete pConnection;
UpdateData(FALSE);
}