http://www.ltp-cloud.com/document/new/#api_rest_error
就像这个网页第一个里面说的我是中国人这句话的句法分析,然后用C++实现httppost请求,网上有不少地方都有相似的代码,可以说是完全一样的代码,但是运行出来根本就不对,
如下:
参考资料:
http://apps.hi.baidu.com/share/detail/39003388
http://blog.csdn.net/yc0188/article/details/4741871
http://bbs.chinaunix.net/thread-2094334-1-1.html
//头文件
#include
#include
#include
usingnamespacestd;
//函数声明
intrequest(char*hostname,char*api,char*parameters);
//方法调用
int_tmain(intargc,TCHAR*argv[],TCHAR*envp[])
{
intnRetCode=0;
//initializeMFCandprintanderroronfailure
if(!AfxWinInit(::GetModuleHandle(NULL),NULL,::GetCommandLine(),0))
{
//TODO:changeerrorcodetosuityourneeds
_tprintf(_T("FatalError:MFCinitializationfailed\n"));
return1;
}
request("reg.163.com","http://reg.163.com/CheckUser.jsp","test");
returnnRetCode;
}
//函数实现
intrequest(char*hostname,char*api,char*parameters)
{
WSADATAWsaData;
WSAStartup(0x0101,&WsaData);
//初始化socket
structhostent*host_addr=gethostbyname(hostname);
if(host_addr==NULL)
{
couth_addr_list);
intsock=socket(AF_INET,SOCK_STREAM,0);
if(sock==-1)
{
return-100;
}
//建立连接
if(connect(sock,(conststructsockaddr*)&sin,sizeof(sockaddr_in))==-1)
{
cout -->
|