服务器端接口文件配置

来源:互联网 发布:二次元pv制作软件 编辑:程序博客网 时间:2024/05/29 01:56

微信公众号的消息模式是这样的


订阅者将消息发送给微信Sever,微信Sever将这个消息转发给你配置的开发者Sever的接口文件上。


接口文件interface.php

//define your tokendefine("TOKEN", "your_token");valid();function valid(){    $echoStr = $_GET["echostr"];        //valid signature    if (checkSignature()) {        echo $echoStr;//return 'echoStr'        exit;    }}function checkSignature(){    $signature = $_GET["signature"];    $timestamp = $_GET["timestamp"];    $nonce     = $_GET["nonce"];        $token  = TOKEN;    $tmpArr = array(        $token,        $timestamp,        $nonce    );    sort($tmpArr);    $tmpStr = implode($tmpArr);    $tmpStr = sha1($tmpStr);        if ($tmpStr == $signature) {        return true;    } else {        return false;    }}


0 0
原创粉丝点击