用CInternetSession实现HTTP POST登录
来源:互联网 发布:淘宝架设到公众号 编辑:程序博客网 时间:2024/06/07 16:17
最近,在编码时发现,原来使用第三方类库实现的HTTP登录验证对Session的处理不是很理想,于是在网上搜集了一些资料,尝试用 CInternetSession实现HTTP POST登录验证,代码如下:
CString strResultStr;
CInternetSession session;
CHttpConnection *pConnection;
CHttpFile *pFile;
BOOL retFlag;
CString strUserName = "jackongxp@163.com";
CString strPassword = "666666";
//与服务器建立连接
pConnection = session.GetHttpConnection( "www.XXXXX.com" );
CString strHeaders, tempStr;
strHeaders = _T("Content-Type: application/x-www-form-urlencoded");
//登录页面为 www.XXXXX.com/Client/Login.aspx
pFile=pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, "/Client/Login.aspx?");
CString strUserinfo;
//在登录页面中主要有两个输入控件,为TextBoxUserName、TextBoxPassword,分别输入用户名和密码
strUserinfo.Format( "TextBoxUserName=%s&TextBoxPassword=%s", strUserName, strPassword );
BOOL result = pFile->SendRequest(
strHeaders,
(LPVOID)(LPCTSTR)strUserinfo, strUserinfo.GetLength() );
//将登录验证后服务器返回的信息放入strResultStr中
do
{
pFile->SetReadBufferSize(10*1024);
retFlag = pFile->ReadString(tempStr);
strResultStr += tempStr + "/n";
}while(retFlag != FALSE);
- 用CInternetSession实现HTTP POST登录
- 用CInternetSession实现HTTP POST登录
- 用CInternetSession实现HTTP POST登录
- 用Httpclient来Post表单实现登录
- 使用CInternetSession代理访问HTTP
- win32 http post 实现
- 用CInternetSession下载文件
- CInternetSession
- CInternetSession
- C++实现Http Post请求
- C++实现Http Post请求
- C++实现Http Post请求
- java实现http post请求
- Java实现HTTP POST方式
- java 实现http POST请求
- 使用 CInternetSession 封装多线程 http 文件下载
- 使用 CInternetSession 封装多线程 http 文件下载
- 使用 CInternetSession 封装多线程 http 文件下载
- C语言算法速查手册
- CE SD卡驱动开发(Zylonite)(转)
- JAVA
- 2440从sd卡启动wince
- PHP 制作通讯录(一)
- 用CInternetSession实现HTTP POST登录
- ASE v15中的应用程序跟踪tracefile特性
- 永远的朋友
- C# 4.0的一些新特性
- 函数fileno的学习
- Qcon大会小记:淘宝开源~
- 大型Oracle数据库迁移解决方案
- 用FILE创建文件
- linux线程的优先级设置