微信(服务器配置)
2016-03-05 16:36
507 查看
微信入门001(服务器配置)
通过url+token =è返回signature+timestamp+nonce+echostr
timestamp+nonce+ token 排序+sha1 加密=比较signature是否相等
注意:
url: 只能是备案的80 域名
token:32位随机数
timestamp:时间戳
nonce:随机数
echostr:随机字符串
代码如下:一般处理程序
结果 :
微信调试技巧:记得打开w3wp.exe 附件进程
通过url+token =è返回signature+timestamp+nonce+echostr
timestamp+nonce+ token 排序+sha1 加密=比较signature是否相等
注意:
url: 只能是备案的80 域名
token:32位随机数
timestamp:时间戳
nonce:随机数
echostr:随机字符串
代码如下:一般处理程序
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Web; using System.Security.Authentication; using System.Security.Cryptography; using System.Web.Security; namespace WebApplication1 { /// <summary> /// wx 的摘要说明 /// </summary> public class wx : IHttpHandler { private string token = "hHneE6EtBEHxNamAkTsCvz5pA3mHWxT"; public void ProcessRequest(HttpContext context) { var url = context.Request.RawUrl; // /?signature=28b94e012e1d698990faf96460a904e334699c6b&echostr=3153896548757110783×tamp=1457086219&nonce=1453006066 //context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); //三个参数排序 ==>放入数组中 var signature = context.Request.QueryString["signature"]; var timestamp = context.Request.QueryString["timestamp"]; var nonce = context.Request.QueryString["nonce"]; var echostr = context.Request.QueryString["echostr"]; var arr = new[] { token, timestamp, nonce }; Array.Sort(arr); var tmepstr = string.Join("", arr); var tempsignature= FormsAuthentication.HashPasswordForStoringInConfigFile(tmepstr, "SHA1").ToLower(); if (signature == tempsignature) { context.Response.Write(echostr); } } public bool IsReusable { get { return false; } } } }
结果 :
微信调试技巧:记得打开w3wp.exe 附件进程
相关文章推荐
- 微信开发系列(二)_配置服务器并验证有效性
- 微信开发系列(一)_对微信的初步了解
- 仿微信引导界面PageAdapter
- Android仿微信实现快速索引选择联系人
- 微信浏览器取消缓存的方法
- 微信企业号平台开发之获取菜单,创建菜单和删除菜单
- java小程序
- 【微信生态圈】-谈谈我的学习经验
- 微信的优缺点以及发展史
- 今天本来还打算继续更新微信开发的,但是没办法接口调用次数已经达到上限了,唉
- 夺命雷公狗---微信开发43----用户分组管理接口(删)
- 夺命雷公狗---微信开发43----用户分组管理接口(改)
- 微信js sdk 分享 失败 有时候好 有时候坏
- 微信第三方登陆
- 2016年春节腾讯手机QQ,微信,春晚支付宝抢红包时刻表分享
- 微信常见问题
- ios 微信朋友圈 开发技术分析
- 微信移动支付服务端php
- 微信公众平台开发学习记录(3)————接收消息和发送回复消息
- 微信开发笔记——微信网页登录授权,获取用户信息