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
//回调页面带回来的授权码
$auth_code = $_GET['auth_code'];
$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',
],
];
$app = new \Chunhei2008\EasyOpenWechat\Foundation\Application($config);
//通过authorization对象获取公众号的基本信息(refresh_token等信息都在里面),这里面已经包含处理了refresh_token的存储,所以不用再去处理refresh_token
$auth_info = $app->authorization->setAuthorizationCode($auth_code)->getAuthorizationInfo();
//$auth_info 是一个AuthorizationInfo对象,可以通过属性获取公众号授权信息的对应属性
$auth_info->authorizer_appid;
$auth_info->authorizer_access_token;