微信接口配置需要用到http开头的域名,然后将自己的api.php路径填写正确 如下
下面是api.php文件的代码
<?php
/**
* wechat php test
*/
include "WeChat_message.php";
header('Content-type:text');
//define your token
//定义TOKEN密钥
define("TOKEN", "weixin");
//实例化微信对象
$wechatObj = new wechatCallbackapiTest();
//验证成功后注释掉valid方法
$wechatObj->valid();
//开启自动回复功能
$wechatObj->responseMsg();
//定义类文件
class wechatCallbackapiTest
{
//定义checkSignature方法
private function checkSignature(){
// you must define TOKEN by yourself
//判断TOKEN密钥是否定义
if (!defined("TOKEN")) {
//如果没有定义则抛出异常,返回'TOKEN is not defined!'字符串
throw new Exception('TOKEN is not defined!');
}
//接收微信加密签名
$signature = $_GET["signature"];