You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
803 B
38 lines
803 B
<?php
|
|
|
|
namespace tencent\wechat\weixin;
|
|
|
|
use EasyWeChat\Factory;
|
|
|
|
class Auth extends Base
|
|
{
|
|
|
|
/**
|
|
* 授权获取跳转地址
|
|
* @param string $url 授权后重定向的回调链接地址
|
|
* @date 2022-03-16
|
|
*/
|
|
public function getRedirectUrl($url)
|
|
{
|
|
$app = Factory::officialAccount($this->weixinConfig);
|
|
|
|
$redirect_url = $app->oauth->scopes(['snsapi_userinfo'])->redirect($url);
|
|
|
|
return $redirect_url;
|
|
}
|
|
|
|
/**
|
|
* Auth2.0 接收用户授权后的状态,并获取用户信息
|
|
* @param string $code 授权码
|
|
* @date 2022-03-16
|
|
*/
|
|
public function getUserInfoByCode($code)
|
|
{
|
|
$app = Factory::officialAccount($this->weixinConfig);
|
|
|
|
$data = $app->oauth->userFromCode($code);
|
|
|
|
return $data;
|
|
}
|
|
}
|