#include <wx/sstream.h>
#include <wx/protocol/http.h>
void OneKeySignDialog::OnButton1Click(wxCommandEvent& event)
{
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();
// reference: http://wiki.wxwidgets.org/WxHTTP
}
wxWidgets http post method example
最新推荐文章于 2024-06-12 09:49:39 发布