C#????????????-?????????Demo??
???????????? ???????[ 2014/6/12 11:07:05 ] ????????C# ??? net
?????????????????????????????????????д??????????????????????????????????????????????url???????????????????????????echostr?????????????
1 //?????????url?????????echoStr
2 public void InterfaceTest()
3 {
4 string token = "??д??token";
5 if (string.IsNullOrEmpty(token))
6 {
7 return;
8 }
9
10 string echoString = HttpContext.Current.Request.QueryString["echoStr"];
11 string signature = HttpContext.Current.Request.QueryString["signature"];
12 string timestamp = HttpContext.Current.Request.QueryString["timestamp"];
13 string nonce = HttpContext.Current.Request.QueryString["nonce"];
14
15 if (!string.IsNullOrEmpty(echoString))
16 {
17 HttpContext.Current.Response.Write(echoString);
18 HttpContext.Current.Response.End();
19 }
20 }
|
??????????????ashx??ProcessRequest????????????????????url??д???????ashx????????????token????????????????????????????????е?token?????????д????£?????????????????????
???????????
????????????Щ????????????????????Щ???????????????????????????????????????????á????????????????????http://mp.weixin.qq.com/wiki/index.php?title=????????????????????????????????Щ????????????????????????y???????????????????????????????????????????????
????click?? ??????click???????????????????????????????????????event ?????????????ο???????????????????????п???????д??key?????????????????????key?????????н?????
????view?? ??????view?????????????????????????????????д??url? ?????????????????????????????????????????????????????????????????????????????
????click???????????key????????????????????????????????view?????????????????????????json???????????php????????C#???????????????post???????json????????????
1 public partial class createMenu : System.Web.UI.Page
2 {
3 protected void Page_Load(object sender?? EventArgs e)
4 {
5 FileStream fs1 = new FileStream(Server.MapPath(".")+"\menu.txt"?? FileMode.Open);
6 StreamReader sr = new StreamReader(fs1?? Encoding.GetEncoding("GBK"));
7 string menu = sr.ReadToEnd();
8 sr.Close();
9 fs1.Close();
10 GetPage("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=access_token"?? menu);
11 }
12 public string GetPage(string posturl?? string postData)
13 {
14 Stream outstream = null;
15 Stream instream = null;
16 StreamReader sr = null;
17 HttpWebResponse response = null;
18 HttpWebRequest request = null;
19 Encoding encoding = Encoding.UTF8;
20 byte[] data = encoding.GetBytes(postData);
21 // ???????...
22 try
23 {
24 // ???ò???
25 request = WebRequest.Create(posturl) as HttpWebRequest;
26 CookieContainer cookieContainer = new CookieContainer();
27 request.CookieContainer = cookieContainer;
28 request.AllowAutoRedirect = true;
29 request.Method = "POST";
30 request.ContentType = "application/x-www-form-urlencoded";
31 request.ContentLength = data.Length;
32 outstream = request.GetRequestStream();
33 outstream.Write(data?? 0?? data.Length);
34 outstream.Close();
35 //?????????????????????
36 response = request.GetResponse() as HttpWebResponse;
37 //???request.GetResponse()???????????????????Post????
38 instream = response.GetResponseStream();
39 sr = new StreamReader(instream?? encoding);
40 //???????????html??????
41 string content = sr.ReadToEnd();
42 string err = string.Empty;
43 Response.Write(content);
44 return content;
45 }
46 catch (Exception ex)
47 {
48 string err = ex.Message;
49 return string.Empty;
50 }
51 }
52 }
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11