WmptWeixin/weixinHelper.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections.Specialized;
using System.Web.Security;
using System.Collections;
using WMPT.Common;
using System.Reflection;
using System.IO;
namespace WMPT.Weixin
{
/// <summary>
/// 此类主要处理微信相关功能
/// </summary>
public class weixinHelper
{
const string token = "ihangjing.com";//微信平台设置的
const string AssemblyPath = "WMPT.Weixin";//用于反射
protected HttpContext context;
public weixinHelper(HttpContext _context)
{
context = _context;
}
/// <summary>
/// 通过签名,判断是否来自微信的请求,如果是返回 echostr,否则返回error
/// 加密/校验流程:
/// 1. 将token、timestamp、nonce三个参数进行字典序排序
/// 2. 将三个参数字符串拼接成一个字符串进行sha1加密
/// 3. 开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
/// </summary>
/// <returns></returns>
public string isValidRequest()
{
string flag = "error";
NameValueCollection coll;
coll = context.Request.Params;
String[] requestarr = coll.AllKeys;
string signature = coll["signature"];
string[] usetovalue = { "token", "nonce", "timestamp" };
string[] Sortedstr = weixinHelper.BubbleSort(usetovalue);
StringBuilder originalstr = new StringBuilder();
foreach (var item in Sortedstr)
{
originalstr.Append(coll[item]);
if (item == "token")
{
originalstr.Append(token);
}
}
后面还有 133 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
