自学内容网 自学内容网

微信公众号服务器配置(PHP服务器设置方法)

本文介绍如何填写微信公众号服务器配置,让PHP服务器配对成功!

一、字段填写

1、在自己的服务器上新建一个wxVerify.php文件(注:文件名可以自己取),然后将此文件的URL填写到配置中。

2、Token自由发挥随便写;

3、EncodingAESKey用随机生成;

二、自己的服务器设置

参考开发文档:https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html

打开自己服务器上的wxVerify.php,编写如下代码:

<?php

//https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html

if(checkSignature()) {
$echostr = $_GET['echostr'];
echo $echostr;
}

function checkSignature()
{
    $signature = $_GET["signature"];
    $timestamp = $_GET["timestamp"];
    $nonce = $_GET["nonce"];
$token = "填写你的Token";

    $tmpArr = array($token, $timestamp, $nonce);
    sort($tmpArr, SORT_STRING);
    $tmpStr = implode( $tmpArr );
    $tmpStr = sha1( $tmpStr );
    
    if( $tmpStr == $signature ){
        return true;
    }else{
        return false;
    }
}

三、提交

填写好服务器设置字段,以及在服务器编写好字段后,提交后就配对成功了!

 


原文地址:https://blog.csdn.net/zgyulongfei/article/details/140612636

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!