This is a chat robot, very convenient, direct call Turing machine Person API can, dialogue way a ask a answer!
There are only PHP and Java examples on the Turing network, so I wrote a Windows.
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.windows.forms;using system.net;using System.IO;using newtonsoft.json;//program needs to refer to Newtonsoft.json http://json.codeplex.com/namespace tuling{public partial class Mainform:form {HttpWebResponse Response = null; Public MainForm () {InitializeComponent (); }//////<summary> dialogue Turing person///</summary>//<param name= "p_strmess Age "></param>///<returns></returns> public string connecttuling (string p_strmessage) {string result = NULL; try {//Registration code yourself to online registration to String APIKEY = "C32ccaa805b6441be76bc18074f12e51"; String _strmessage = p_strmessage; String INFO = Encoding.UTF8.GetString (Encoding.UTF8.GetBytes (_strmeSsage)); String GetURL = "http://www.tuling123.com/openapi/api?key=" + APIKEY + "&info=" + info; HttpWebRequest myrequest = (HttpWebRequest) httpwebrequest.create (GetURL); HttpWebResponse myresponse = (HttpWebResponse) myrequest.getresponse (); Response = Myresponse; using (Stream MyStream = Myresponse.getresponsestream ()) {Long progmaximum = Myresponse . ContentLength; Long totaldownloadedbyte = 0; Byte[] by = new byte[1024]; int osize = Mystream.read (by, 0, by.) Length); Encoding Encoding = Encoding.UTF8; while (Osize > 0) {totaldownloadedbyte = osize + totaldownloadedbyte; Result + = encoding. GetString (by, 0, osize); Long progvalue = Totaldownloadedbyte; Osize = MYSTREAM.READ (by, 0, by.) Length); }}//parsing json jsonreader reader = new JsonTextReader (new StringReader (Result)) ; while (reader. Read ()) {The content in//text is the IF (reader) you need. path== "text") {//Results assignment result = reader. Value.tostring (); } Console.WriteLine (reader. Tokentype + "\t\t" + reader. ValueType + "\t\t" + reader. Value); }} catch (Exception) {throw; } return result; private void Btn_send_click (object sender, EventArgs e) {string returnmess = Connec Ttuling (rtb_send. Text); Rtb_mess. Text = returnmess; private void Btn_close_click (object sender, EventArgs e) {this.this.FindForm (). Close (); } <summary>///Enter shortcut keys///</summary>//<param name= "Sender" ></param> <param name= "E" ></param> private void Rtb_send_keydown (object sender, KeyEventArgs e) {if (E.keycode = = keys.enter) {rtb_mess. text= connecttuling (rtb_send. Text); } } } }
Smart chat robot with fast implementation in C #