1,接口是通过HTTP GET提供的,地址是
http://www.tuling123.com/openapi/api?key=注册码&code=上下文ID&info=内容
注册码只要在网站上中注册就有了;code为上下文ID,第一次不用传,以后只要将返回的ID附上即可;内容为和机器人交谈的内容,URL UTF-8编码。
返回内容为json格式,UTF-8编码。
2,C++实现:
CString GetParam(CString httpsource, LPCTSTR lpszSpliter)
{
int iStart, iEnd;
CString strPara = TEXT("");
if ((iStart = httpsource.Find(lpszSpliter)) != -1)
{
iStart += lstrlen(lpszSpliter);
if ((iEnd = httpsource.Find(TEXT(","), iStart)) != -1)
{
strPara = httpsource.Mid(iStart, iEnd - iStart);
}
else
{
strPara = httpsource.Mid(iStart, httpsource.GetLength() - i