1. 新注册的Gmail邮箱 登录为什么取不到欢迎页面 GET /mail/help/intl/zh-CN/intro.html
急。。。大家给点意见把
BOOL OpenMail(char* szUser,char* szPassword)
{
BOOL bResult = FALSE;
//char szLogonUrl[] = "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl";
char szLogonUrl[] = "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl<mpl=yj_blanco<mplcache=2";
char szPostUrl[] = "https://www.google.com/accounts/ServiceLoginAuth";
HINTERNET hOpenRequest;
HINTERNET hConnect;
HINTERNET hSession;
char * szBuf = (char*)malloc(BUF_LEN);
char * szPostData = (char*)malloc(BUF_LEN);
char szViewPageUrl[4096];
char cookie_at[MAX_PATH] = {0};
DWORD dwLen = BUF_LEN;
DWORD dwRet;
DWORD bytes=0;
CString strServer;
CString strObject;
INTERNET_PORT nPort ;
DWORD dwServiceType;
char* szTmp;
char* szTmp1;
char* purl;
BOOL bRet;
CStringArray strlistCookies;
char prop_continue[] = "http%3A%2F%2Fmail.google.com%2Fmail%2F%3F";
char prop_service[] = "mail";
char prop_rm[] = "false";
char prop_null[] = "Sign+in";
DWORD i;
try
{
hSession=InternetOpen(NULL,
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0) ;
if(!hSession)
{
throw("Error:InternetOpen@GetCreateUrl!");
}
//if(hOpenRequest = ::InternetOpenUrl(hSession,"http://mail.google.com",NULL,0,0,NULL))
//{
// ::InternetCloseHandle(hOpenRequest);
//}
if( !AfxParseURL(szPostUrl,dwServiceType, strServer, strObject, nPort) )
//if( !AfxParseURL("202.181.27.48",dwServiceType, strServer, strObject, nPort) )
{
throw("AfxParseUrl Error");
}
hConnect = ::InternetConnect(hSession, strServer, nPort, NULL, NULL, INTERNET_SERVICE_HTTP,0,0);
if(!hConnect)
{
TRACE("Error:InternetConnectt--%d",GetLastError());
throw("Error:HttpSendRequest");
}
//hOpenRequest = HttpOpenRequest(hConnect,"POST",strObject,NULL,szLogonUrl,NULL,INTERNET_FLAG_SECURE | INTERNET_FLAG_NO_AUTO_REDIRECT,0);
hOpenRequest = HttpOpenRequest(hConnect,"POST",strObject,NULL,szLogonUrl,NULL,INTERNET_FLAG_SECURE ,0);
if(!hOpenRequest)
{
throw("Error:HttpOpenRequest");
}
sprintf(szPostData,"ltmpl=yj_blanco<mplcache=2&continue=http%%3A%%2F%%2Fmail.google.com%%2Fmail%%2F%%3F&service=mail&rm=false<mpl=yj_blanco&Email=%s&Passwd=%s&rmShown=1&null=%%E7%%99%%BB%%E5%%BD%%95",
szUser,
szPassword
);
sprintf(szBuf, RHEADER_LOGIN_SETP_1, strlen(szPostData) );
if(!HttpAddRequestHeaders(hOpenRequest,szBuf,strlen(szBuf),HTTP_ADDREQ_FLAG_ADD_IF_NEW))
{
throw("Error:HttpAddRequestHeaders");
}
if( !HttpSendRequest(hOpenRequest,NULL,0,szPostData,strlen(szPostData) ) )
{
TRACE("Error:HttpSendRequest--%d",GetLastError());
throw("Error:HttpSendRequest");
}
dwLen = BUF_LEN;
// bRet = HttpQueryInfo(hOpenRequest, HTTP_QUERY_LOCATION,szBuf, &dwLen, NULL);
bRet = HttpQueryInfo(hOpenRequest, HTTP_QUERY_STATUS_CODE,szBuf, &dwLen, NULL);
if (bRet)
dwRet = (DWORD) atol(szBuf);
问题点数:20、回复次数:0Top




