2012-01-24 33 views
0

我還沒有看到任何通過輸入某些字符串來調用XML-RPC的文檔,並通過連接到XML API來獲取C++中某些字符串的響應。這是服務器提供的文檔。我無法弄清楚如何做到這一點C++ XML-RPC調用

A client can interact with a Pandorabot by POST'ing to: 

    http://www.pandorabots.com/pandora/talk-xml 
    The form variables the client needs to POST are: 

    botid - see H.1 above. 
    input - what you want said to the bot. 
    custid - an ID to track the conversation with a particular customer. This variable is optional. If you don't send a value Pandorabots will return a custid attribute value in the <result> element of the returned XML. Use this in subsequent POST's to continue a conversation. 
    This will give a text/xml response. For example: 

    <result status="0" botid="c49b63239e34d1d5" custid="d2228e2eee12d255"> 
     <input>hello</input> 
     <that>Hi there!</that> 
    </result> 

    The <input> and <that> elements are named after the corresponding AIML elements for bot 
input and last response. 
If there is an error, status will be non-zero and there will be a human readable <message> element included describing the error. 

For example: 
    <result status="1" custid="d2228e2eee12d255"> 
     <input>hello</input> 
     <message>Missing botid</message> 
    </result> 
+0

這對我來說看起來不像實際的[XML-RPC](http://en.wikipedia.org/wiki/XML-RPC)協議。 –

回答

0

在C++中通過HTTP進行通信的最簡單方法是使用專門爲此目的設計的庫。例如,libcurl提供了您需要發送和接收您在問題中顯示的請求和回覆的所有設施。

+0

cURL for C++不提供任何文檔,請問您可以告訴如何執行此操作? –

+0

所有的libcurl文檔都可以在[API](http://curl.haxx.se/libcurl/c/)頁面找到。你將使用C接口(它也可以在C++中使用)。在那裏使用「Easy界面」。 –

+0

我coudn't看如何設置字符串(像botid custid變量),並要求一個答覆 –