DTcms.Web/api/weixin/wx.aspx.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.IO;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTcms.API.Weixin.Handler;
using DTcms.Common;
namespace DTcms.Web.api.weixin
{
public partial class wx : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string token = string.Empty; //与微信公众账号后台的Token设置保持一致,区分大小写。
int uid = DTRequest.GetQueryInt("uid",0);
if (uid == 0)
{
WriteContent("参数非法");
return;
}
token = new BLL.weixin_account().GetToken(uid); //获取公众账户的ToKen
if (string.IsNullOrEmpty(token))
{
WriteContent("不存在的公众账户!");
return;
}
//获取微信传送参数
string signature = Request["signature"];
string timestamp = Request["timestamp"];
string nonce = Request["nonce"];
string echostr = Request["echostr"];
if (Request.HttpMethod == "GET")
{
//GET-仅在微信后台填写URL验证时触发
if (Senparc.Weixin.MP.CheckSignature.Check(signature, timestamp, nonce, token))
{
WriteContent(echostr); //返回随机字符串则表示验证通过
}
else
{
WriteContent("failed:" + signature + ",token:" + token + " " + Senparc.Weixin.MP.CheckSignature.GetSignature(timestamp, nonce, token) + "。" +
"如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。");
}
Response.End();
}
else
{
//POST-当有用户想公众账号发送消息时触发
if (!Senparc.Weixin.MP.CheckSignature.Check(signature, timestamp, nonce, token))
{
WriteContent("参数错误!");
return;
}
//可以设置每个人上下文消息储存的最大数量,防止内存占用过多,如果该参数小于等于0,则不限制
var maxRecordCount = 10;
后面还有 43 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。