我在GetHttpConnection中使用CInternetSession,但是我在任何地方都找不到关于如何填写和发布web表单的好信息。
发布于 2011-12-20 00:10:14
This knowledge base article解释了如何使用CInternetSession模拟POST请求。
包含的示例代码如下所示:
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded");
// URL-encoded form variables -
// name = "John Doe", userid = "hithere", other = "P&Q"
CString strFormData = _T("name=John+Doe&userid=hithere&other=P%26Q");
CInternetSession session;
CHttpConnection *pConnection = session.GetHttpConnection(_T("ServerNameHere"));
CHttpFile *pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,
_T("FormActionHere"));
BOOL result = pFile->SendRequest(strHeaders, (LPVOID) (LPCTSTR) strFormData,
strFormData.GetLength());https://stackoverflow.com/questions/8563975
复制相似问题