怎么设置微信公众号服务器配置?

¥20.00
微信公众号怎么接入服务器配置呀?在线等,急!

最佳解决方案

1.url:填写微信能够访问到的url地址。
2.Token: 自定一段参数。例子:test001
3.EncodingAESKey:随机生成
4.在上面配置url服务端写上验证token代码。下面以C#为示例:

protected void Page_Load(object sender, EventArgs e)
    {
        string token = "test001";
        if (string.IsNullOrEmpty(token))
        {
            return;
        }
        string echoString = HttpContext.Current.Request.QueryString["echoStr"];
        string signature = HttpContext.Current.Request.QueryString["signature"];
        string timestamp = HttpContext.Current.Request.QueryString["timestamp"];
        string nonce = HttpContext.Current.Request.QueryString["nonce"];
        if (CheckSignature(token, signature, timestamp, nonce))
        {
            if (!string.IsNullOrEmpty(echoString))
            {
                Response.Write(echoString);
                Response.End();
            }
        }
    }
    public static bool CheckSignature(string token, string signature, string timestamp, string nonce)
    {
        string[] ArrTmp = { token, timestamp, nonce };
        //字典排序
        Array.Sort(ArrTmp);
        //拼接
        string tmpStr = string.Join("", ArrTmp);
        //sha1验证
        tmpStr = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1");
        //tmpStr = Membership.CreateUser(tmpStr, "SHA1");
        tmpStr = tmpStr.ToLower();
        if (tmpStr == signature)
        {
            return true;
        }
        else
        {
            return false;
        }
    }


嗝屁猫 T2 被采纳率89%
2021-03-02 17:56
打赏 0 1
页面统计
1114 访问
0 帮助
0.00 打赏

hierror 2019 © hierror.com 京ICP备13026190号-1

通知消息
  • 暂无任何消息