求助 关于 wxWidgets WXHTTP

这是wxWidgets论坛的中文版本。在这里,您可以用您的母语汉语讨论上面任一子论坛所涉及的所有关于wxWidgets的话题。欢迎大家参与到对有价值的帖子的中英互译工作中来!
Post Reply
ma12155506
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Jul 02, 2012 2:32 am

求助 关于 wxWidgets WXHTTP

Post by ma12155506 »

我想请求URL 类似 http://www.xxx.com/index.php?m=ring&c=j ... "+password 返回为json的数据格式 我如何请求 和获取
WXHTTP ::GetResponse() 的用法 。。。
kipade
Earned some good credits
Earned some good credits
Posts: 126
Joined: Fri Nov 11, 2011 2:45 am
Location: China

Re: 求助 关于 wxWidgets WXHTTP

Post by kipade »

看见沉了这么久的贴子,有点感慨
楼上的提问不太明确
以后常来逛逛
Slackware GNU/Linux x86_64
wxWidgets-3.3.0
superosx
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Sep 10, 2012 6:30 am

Re: 求助 关于 wxWidgets WXHTTP

Post by superosx »

wxHTTP h;
wxString res;
h.SetTimeout(10);
h.SetHeader( _T("Accept") , _T("*/*") );
h.SetHeader( _T("User-Agent") , _T("Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.2;)") );
h.SetHeader( _T("Connection") , _T("keep-alive") );
h.SetHeader( _T("Referer") , _T("http://www.xxx.com/"));
h.SetHeader( _T("Cookie") , _T("cookiestring") );
h.Connect( "www.xxx.com" );
wxCSConv charset(_T("UTF-8"));//根据自己的需求设置编码
wxInputStream *data = h.GetInputStream( "/index.php?a=xx&b=xx&c=xx" );
wxStringOutputStream out_stream( &res ,charset);
if ( h.GetError() == wxPROTO_NOERR)
{
data->Read(out_stream);
}
else
{
//error
}
wxDELETE(data);
h.Close();
wxMessageBox( wxT(res) );
Post Reply