CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C/C++ >  C++ 语言

1. 新注册的Gmail邮箱 登录为什么取不到欢迎页面 GET /mail/help/intl/zh-CN/intro.html

楼主vcjob(vc)2006-11-01 16:49:32 在 C/C++ / C++ 语言 提问

急。。。大家给点意见把  
  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&ltmpl=yj_blanco&ltmplcache=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&ltmplcache=2&continue=http%%3A%%2F%%2Fmail.google.com%%2Fmail%%2F%%3F&service=mail&rm=false&ltmpl=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

相关问题

关键词

得分解答快速导航

  • 帖主:vcjob

相关链接

  • C/C++ Blog
  • C/C++类图书
  • C/C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo