This repository has been archived by the owner on Aug 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
公众号消息处理
wangyi edited this page Dec 22, 2016
·
1 revision
保持和EasyWeChat一致
//通过公众号消息与事件接收URL可以处理获取公众号app_id
$app_id = $_REQUEST['app_id'];
$config = [
'debug' => true,
'component_app_id' => 'wxd954……', //第三方平台app id
'component_app_secret' => 'a7a48d271…………', //第三方平台app secret
'token' => 'easy-open-wechat-token', //公众号消息校验Token
'aes_key' => '90ID6sSTuY……Uh6BWDct', //公众号消息加解密Key
'redirect_uri' => 'http://yourhostname/authcallback.php', //公众号授权回调页面
'log' => [
'level' => 'debug',
'file' => '/tmp/easyopenwechat.log',
],
];
$config['app_id'] = $app_id;
$app = new \Chunhei2008\EasyOpenWechat\Foundation\Application($config);
//wechat实际上是一个EasyWeChat的app对象
$wechat = $app->wechat;
//下面的使用就跟EasyWeChat一模一样了,里面已经封装了公众号授权事件的处理
$response = $wechat->server->setMessageHandler(function ($message) {
return "您好!欢迎关注我! this is easy open wechat";
})->serve();
$response->send();