http://mp.weixin.qq.com/wiki/17/2d4265491f12608cd170a95559800f2d.html
这是微信公众平台提供的接入指南。官网只提供了php的示例代码,这里我提供一份C#的接入示例代码,只需要修改web.config中对应的配置[token]就可以使用了
值得注意的是,你需要申请一个域名,把这个网站发布出去,绑定你申请的域名,然后把对应的信息填写到
选择安全模式,因为代码里边已经进行了加密处理,url里填写之前申请到的域名,encodingAESkey随机生成。
········································别忘了绑定域名哦····································································
主要代码片段:
/// <summary> /// 对字符串进行SHA1加密 /// </summary> /// <param name="strIN">需要加密的字符串</param> /// <returns>密文</returns> public string SHA1_Encrypt(string Source_String) { byte[] StrRes = Encoding.Default.GetBytes(Source_String); HashAlgorithm iSHA = new SHA1CryptoServiceProvider(); StrRes = iSHA.ComputeHash(StrRes); StringBuilder EnText = new StringBuilder(); foreach (byte iByte in StrRes) { EnText.AppendFormat("{0:x2}", iByte); } return EnText.ToString(); }
List<String> strs = new List<string>(); strs.Add(token); strs.Add(timestamp); strs.Add(nonce); strs.Sort();//这里进行字典排序 string GetStr = ""; strs.ForEach(a => GetStr += a);//得到排序后的字符串
代码文件下载链接: http://pan.baidu.com/s/1dDczaTz 密码: 6cc4
时间: 2024-11-05 03:44:39