Posting data to web
-
Currently I am using the following piece of code to post data to a website
HRESULT hResult; hResult = HttpRequest.CreateInstance("Microsoft.XMLHTTP"); if ( FAILED(hResult) ) return bRetVal; //error VARIANT vAsync; vAsync.vt = VT_BOOL; vAsync.boolVal = FALSE; VARIANT vUser; vUser.vt = VT_BSTR; vUser.bstrVal = NULL; VARIANT vPassword; vPassword.vt = VT_BSTR; vPassword.bstrVal = NULL; HttpRequest->open("POST", "http://web.cgi", vAsync, vUser, vPassword); HttpRequest->setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); CString szRequest = "static=1&entry_id=328&name=R&email=r@r.com"; VARIANT vRequest; vRequest.vt = VT_BSTR; vRequest.bstrVal = szRequest.AllocSysString(); //Send Http Request HttpRequest->send(vRequest); //Read response and status // m_lHttpStatus = HttpRequest->status; m_szHttpStatusText = (char*)HttpRequest->statusText; _bstr_t bsResponse = HttpRequest->responseText;
Everything is going fine the data is posted through the code and OK is retutrned. But when i view the website the data is not there. It seemd that the data is not posted to the web. Am i doing everything right- Is there any opther way to do so. PLease help me out. -
Currently I am using the following piece of code to post data to a website
HRESULT hResult; hResult = HttpRequest.CreateInstance("Microsoft.XMLHTTP"); if ( FAILED(hResult) ) return bRetVal; //error VARIANT vAsync; vAsync.vt = VT_BOOL; vAsync.boolVal = FALSE; VARIANT vUser; vUser.vt = VT_BSTR; vUser.bstrVal = NULL; VARIANT vPassword; vPassword.vt = VT_BSTR; vPassword.bstrVal = NULL; HttpRequest->open("POST", "http://web.cgi", vAsync, vUser, vPassword); HttpRequest->setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); CString szRequest = "static=1&entry_id=328&name=R&email=r@r.com"; VARIANT vRequest; vRequest.vt = VT_BSTR; vRequest.bstrVal = szRequest.AllocSysString(); //Send Http Request HttpRequest->send(vRequest); //Read response and status // m_lHttpStatus = HttpRequest->status; m_szHttpStatusText = (char*)HttpRequest->statusText; _bstr_t bsResponse = HttpRequest->responseText;
Everything is going fine the data is posted through the code and OK is retutrned. But when i view the website the data is not there. It seemd that the data is not posted to the web. Am i doing everything right- Is there any opther way to do so. PLease help me out.IS your Webserver provide support for Posting data from application. Returning OK means that The Url you requested is Found,this Ok dosn't tell any thing about the your data posting is successful. data posting always come witha html file in return,try to read that file,it may contain possible error description ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk
-
IS your Webserver provide support for Posting data from application. Returning OK means that The Url you requested is Found,this Ok dosn't tell any thing about the your data posting is successful. data posting always come witha html file in return,try to read that file,it may contain possible error description ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk
_bstr_t bsResponse = HttpRequest->responseText;
The above line contains the contents of the HTML Page. But the problem is that It only contains first few lines. The tag is not even complete in the string. Dont know how to get it. Can it be done thru some other way. -
_bstr_t bsResponse = HttpRequest->responseText;
The above line contains the contents of the HTML Page. But the problem is that It only contains first few lines. The tag is not even complete in the string. Dont know how to get it. Can it be done thru some other way.Yeah Buddy, ther is very good Class named AmHttpSocket or amHttpFile in Internet Section , it hink that will help you out. or ucan use InternetReadFile Api's if you dunno want ot use MFC based CInterneSession Class. ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk