wxWidgets http post method example

#include <wx/sstream.h>

#include <wx/protocol/http.h>

wxHTTP http;

http.SetHeader(_T(“Content-type”), _T(“application/x-www-form-urlencoded”)); //remember to define “Content-type: application/x-www-form-urlencoded”, or remote server can’t get your posted data.
http.SetPostBuffer(_(“postdata=content”)); //it’s the data to be posted
http.Connect(_(“example.com”));
wxInputStream *httpStream = http.GetInputStream(_T(“/login.php”));
if (http.GetError() == wxPROTO_NOERR)
{
wxString res;
wxStringOutputStream out_stream(&res);
httpStream->Read(out_stream);
wxMessageBox(res);
// wxLogVerbose( wxString(_T(” returned document length: “)) << res.Length() );
}
else
{
wxMessageBox(_T(“Unable to connect!”));
}
wxDELETE(httpStream);
http.Close();
, ,