请教 我现在想用wininet跟券商的web交易系统 进行交互,该如何进行?
图片是ie上看到的 登录时候用的post方法
我用的是这个代码例子http://www.codeproject.com/Articles/3898/Connecting-to-a-HTTPS-server-with-SSL-using-Winine
m_hInternet = InternetOpen(m_strAgentName.c_str(), INTERNET_OPEN_TYPE_PRECONFIG ,
NULL, NULL, 0);
m_hSession = InternetConnect(m_hInternet,
m_strServerName.c_str(), //string sServerName("trade.ctsec.com")
m_wPort,//443
m_strUserName.c_str(), //""
m_strPassword.c_str(),//""
INTERNET_SERVICE_HTTP,
0,
0);
m_hRequest = HttpOpenRequest(m_hSession,
strVerb.c_str(),// POST
m_strObjectName.c_str(),//"/login.php?do=login" 是否在这里加post请求正文?
NULL,
"",
NULL,
m_secureFlags, //m_secureFlags = INTERNET_FLAG_RELOAD|INTERNET_FLAG_KEEP_CONNECTIO N|INTERNET_FLAG_NO_CACHE_WRITE|
INTERNET_FLAG_SECURE|INTERNET_FLAG_IGNORE_CERT_CN_INVALID;
m_ReqID);
bool CSslConnection::SendHttpsRequest()
{
try {
for (int tries = 0; tries < 20; ++tries) {
int result = HttpSendRequest(m_hRequest, NULL, 0, NULL, 0);
if (result)
return true; //到这里都会返回true 后面都没执行过 然后就去执行GetRequestResult
int lastErr = GetLastError();
if (lastErr == ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED) {
if (!SetClientCert()) {
m_strLastError = "Cannot perform http request, client authentication needed but couldnt detect required client certificate";
m_lastErrorCode = GetLastError();
return false;
}
}
else if (lastErr == ERROR_INTERNET_INVALID_CA) {
m_strLastError = "Cannot perform http request, client authentication needed, invalid client certificate is used";
m_lastErrorCode = GetLastError();
return false;
}
else {
m_strLastError = "Cannot perform http request";
m_lastErrorCode = GetLastError();
return false;
}
}
}
catch(...) {
m_strLastError = "Memory Exception occured";
m_lastErrorCode = GetLastError();
return false;
}
return false;
}
string CSslConnection::GetRequestResult()
{
DWORD dwNumberOfBytesRead;
char sz[1024];
string strResult;
int result;
do {
result = InternetReadFile(m_hRequest, sz, 1023, &dwNumberOfBytesRead);
sz[dwNumberOfBytesRead] = '\0';
int x = strlen(sz);
strResult += sz;
memset(sz, 0, 1024);
} while(result && dwNumberOfBytesRead != 0);
return strResult;
}
请问是否在HttpOpenRequest里面的参数 _In_ LPCTSTR lpszObjectName,里面增加请求正文?
ie开发人员工具里面的请求正文如下
yyb_name=1&account_type=0&account=********&crpttype=1&tradekey=********&commkey=********&token=********&embeded=
请大牛帮帮忙 本人不太懂web
分少见谅
------解决思路----------------------
一个模拟登陆的例子,希望对你有所帮助~
http://blog.csdn.net/visualeleven/article/details/6656224