-
Notifications
You must be signed in to change notification settings - Fork 317
oauth_access_token
thenbsp edited this page Mar 3, 2016
·
4 revisions
用户 AccessToken
是通过网页授权所获取的用户接口调用凭证,有效期为 7200
秒,过期后可通过 refresh_token
来刷新。
use Thenbsp\Wechat\OAuth\Client;
$client = new Client('appid', 'appsecret');
if( !isset($_GET['code']) ) {
header('Location: '.$client->getAuthorizeUrl());
}
$accessToken = $client->getAccessToken($_GET['code']);
var_dump($accessToken->isValid());
if( !$accessToken->isValid() ) {
$accessToken->refresh();
}
var_dump($accessToken->toArray());
$userinfo = $accessToken->getUser();
var_dump($userinfo->toArray());