C#创建微信自定义菜单

创建
1 string access_token = "你的token";
2 string posturl = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + access_token; 3 string menuStr = " 菜单结构"; 4 5 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(posturl); 6 request.ContentType = "application/x-www-form-urlencoded"; 7 request.Method = "POST"; 8 9 //ASCIIEncoding encoding = new ASCIIEncoding(); 10 byte[] postdata = Encoding.GetEncoding("UTF-8").GetBytes(menuStr); 11 request.ContentLength = postdata.Length; 12 13 Stream newStream = request.GetRequestStream(); 14 newStream.Write(postdata, 0, postdata.Length); 15 newStream.Close(); 16 17 HttpWebResponse myResponse = (HttpWebResponse)request.GetResponse(); 18 StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); 19 string content = reader.ReadToEnd();//得到结果 20 21 Response.Write(content);
posted @ 2013-08-09 09:09  想飞的咸鱼  阅读(1103)  评论(0编辑  收藏  举报