C#调用
XXXXXXXXXXXXXXXXXXXXXX/ API做的聊天机器人
01
<%@ WebHandler Language="C#" Class="chat" %>
02
03
using System;
04
using System.Web;
05
06
public class chat : IHttpHandler {
07
08
public void ProcessRequest (HttpContext context) {
09
XXXXXXXXXXXXXXXXXXXntentType = "text/plain";10
string msg = XXXXXXXXXXquest["msg"];11
msg = "XXXXXXXXXXXXXXXXXXXXXX/XXXXXXp?key=free&appid=0&msg=" + msg;12
//XXXXXXXXXXsponse.Write(msg);13
Uri myUri = new Uri("XXXXXXXXXXXXXXXXXXXXXX/XXXXXXp?key=free&appid=0&msg="+msg);14
XXXXXXXXXXXXXtpWebRequest myWebRequest = (XXXXXXXXXXXXXtpWebRequest)XXXXXXXXXXXXXXXXXXXXXXXXeate(myUri);15
myWebRequest.Method = "GET";
16
XXXXXXXXXXXXXtpWebResponse myWebResponse = (XXXXXXXXXXXXXtpWebResponse)XXXXXXXXXXXXXXXtResponse();17
XXXXXXXXXXXXreamReader reader = new XXXXXXXXXXXXreamReader(XXXXXXXXXXXXXXXXtResponseStream(), XXXXXXXXXXXXXXXXXXXXXXXtEncoding("utf-8"));18
byte[] buffer = XXXXXXXXXXXXXXXXXXXXXXXtEncoding("utf-8").GetBytes(XXXXXXXXXadToEnd());19
string HTML = XXXXXXXXXXXXXXXXXXXXXXXtEncoding("utf-8").GetString(buffer).Trim();20
HTML = "[" + HTML + "]";
21
string jsonText = HTML;
22
XXXXXXXXXXXXXXXXXXnq.JArray ja = (XXXXXXXXXXXXXXXXXXnq.JArray)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXserializeObject(jsonText);23
string res = ja[0]["content"].ToString();
24
res = XXXXXXplace("{br}", "<br />");25
XXXXXXXXXXsponse.Write(res);26
}
27
28
public bool IsReusable {
29
get {
30
return false;
31
}
32
}
33
34
}
转自 开源中国 CSharp_NET 发布于 2013年08月16日 13时