<?php
/**
* wechat php test
*/
//define your token
define("TOKEN", "weixin");
$wechatObj = new wechatCallbackapiTest();
//$wechatObj->valid();exit;
$wechatObj->responseMsg();
class wechatCallbackapiTest
{
public function valid()
{
$echoStr = $_GET["echostr"];
//valid signature , option
if($this->checkSignature()){
echo $echoStr;
exit;
}
}
//处理业务逻辑
public function responseMsg()
{
//get post data, May be due to the different environments
$postStr = file_get_contents("php://input"); //php 7 以上版本
//$postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; //php 7以下版本,php.ini开启;always_populate_raw_post_data = On
//extract post data 请求数据
if (!empty($postStr)){
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$fromUs
php 微信公众号开发: token 验证
最新推荐文章于 2024-06-30 10:36:14 发布