2 qq 35522672 qq_35522672 于 2016.09.06 16:51 提问

HTTP POST 连接服务的问题 1C

CString header = _T("Content-Type: application/x-www-form-urlencoded");
CInternetSession session;
CHttpConnection* pConnection=NULL;
CHttpFile* pFile=NULL;

INTERNET_PORT nPort = port;
pConnection = session.GetHttpConnection(ip,0,nPort,NULL,NULL);
pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,object);

    我服务器的地址为 http:12.12.12.13:4038/xxx/xxx/xxxx

    我函数里的ip  object 该如何填写。

1个回答

oyljerry
oyljerry   Ds   Rxr 2016.09.06 17:17
 CString strHeaders =_T("Content-Type:   application/x-www-form-urlencoded\r\n");

    CInternetSession session;
    CHttpConnection* pConnection =session.GetHttpConnection("127.0.0.1",(INTERNET_PORT)80); //与服务器建立连接;
    CHttpFile* pFile =pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,"1.php");
    BOOL result = pFile->SendRequest(strHeaders,"sid=1",5);

    pFile->Close(); 
    pConnection->Close();
    delete pFile;
    delete pConnection;
    session.Close();


在 BOOL result = pFile->SendRequest(strHeaders,"sid=1",5);中 
"sid = 1"就是你向网页提交的参数,5是参数的长度 
qq_35522672
qq_35522672 我服务器的地址为 http:12.12.12.13:4038/xxx/xxx/xxxx
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片