基本信息
源码名称:微信公众账号开发 实例源码下载(含SDK)
源码大小:4.12M
文件格式:.zip
开发语言:C#
更新时间:2014-07-28
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
基于.net的轻量级的微信SDK,使用.net Framework4.0的Dynamic特性,一个将xml字符串自动转换成Dynamic Object的DynamicXml.cs类,还有一个将json字符串自动转换成Dynamic Object的DynamicJson.cs类实现无Entity的SDK;代码结构完全符合官方平台的布局,一目了然
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Web; using System.Web.Mvc; using System.Xml.Linq; using Deepleo.Weixin.SDK; using System.Xml; namespace Deepleo.Web.Controllers { public class WeixinController : Controller { public WeixinController() { } /// <summary> /// 微信后台验证地址(使用Get),微信后台的“接口配置信息”的Url /// </summary> [HttpGet] [ActionName("Index")] public ActionResult Get(string signature, string timestamp, string nonce, string echostr) { var token = "123456789";//微信公众平台后台设置的Token if (string.IsNullOrEmpty(token)) return Content("请先设置Token!"); var ent = ""; if (!BasicAPI.CheckSignature(signature, timestamp, nonce, token, out ent)) { return Content("参数错误!"); } return Content(echostr); //返回随机字符串则表示验证通过 } /// <summary> /// 用户发送消息后,微信平台自动Post一个请求到这里,并等待响应XML。 /// </summary> [HttpPost] [ActionName("Index")] public ActionResult Post(string signature, string timestamp, string nonce, string echostr) { WeixinMessage message = null; using (var streamReader = new StreamReader(Request.InputStream)) { message = AcceptMessageAPI.Parse(streamReader.ReadToEnd()); } var response = new WeixinExecutor().Execute(message); return new ContentResult { Content = response, ContentType = "text/xml", ContentEncoding = System.Text.UTF8Encoding.UTF8 }; } } }