调用聊天机器人 -小I机器人

 public static string sendMsg2(string msg)
       {

           try
           {    
                msg = Uri.EscapeDataString( msg);
                string sUrl = "http://i.xiaoi.com/robot/webrobot?data={%22sessionId%22:%228e52024188u65e13782%22,%22robotId%22:%22webbot%22,%22userId%22:%22b472189e640448c8927f3b982d945886%22,%22body%22:{%22content%22:%22"+msg+"%22},%22type%22:%22txt%22}";
                string s = HttpHelper.HttpGet(sUrl);
                string[] sAll =s.Split((char)1);//Trim((char)1).Trim();
                int i = sAll.Length;
                if (i > 1) {
                    i = i - 2;
                }
                if (i == 2)
                {
                    i = 0;
                }
                s= sAll[i].Trim((char)1).Trim();
                JToken  j = JToken.Parse(s);
               // //{"robotId":"webbot","userId":"b472189e640448c8927f3b982d945886","sessionId":"8e52024100404449ba67f903c5e13782","type":"txt","body":{"fontStyle":0,"fontColor":0,"content":"今天是星期三\r\n今天是戊戌年五月廿一\r\n宜:嫁娶.祭祀.沐浴.扫舍.修饰垣墙.\r\n忌:行丧.安葬.\r\n\r\n","emoticons":{}}}
               return "" + j["body"]["content"];

           }
           catch(Exception ex)
           {

               return "";
           }


       }

  

猜你喜欢

转载自www.cnblogs.com/wgscd/p/9263908.html