Stream__
Stan_Shi
2017-11-27 04:27

FMC HTTP POST如何添加body(参数)

10
  • post
  • http
  • fmc

//MFC类CHttpConnection管理与HTTP服务器的连接
CHttpConnection* pConnection = session.GetHttpConnection(TEXT("116.62.11.154"),//服务器IP地址
(INTERNET_PORT)8080);//端口号
CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,//设置为POST方法
TEXT("/mobile/bind.do"),//URL 你要访问的具体的文件(服务器会给你)
NULL,
1,
NULL,
TEXT("HTTP/1.1"),
INTERNET_FLAG_RELOAD);

//header 请求头
pFile->AddRequestHeaders(_T("Host: 116.62.11.154 : 8080"));
pFile->AddRequestHeaders(_T("mobile: 18717791650"));
pFile->AddRequestHeaders(_T("password: 123"));
pFile->AddRequestHeaders(_T("Content-Type: application/x-www-form-urlencoded; charset=UTF-8"));
pFile->AddRequestHeaders(_T("Content-Length: 25"));


CString strUserinfo = _T("binding-device=DY09000105");
pFile->SendRequest(NULL,0, (LPVOID)(LPCTSTR)strUserinfo, strUserinfo.GetLength());//发送请求


DWORD dwRet;
pFile->QueryInfoStatusCode(dwRet);

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答