如何重写 Yii 2.0 框架 vendor 里面的第三方包的方法 [ 2.0 版本 ]
大家好啊,请问一下哈,我现在有一个需求,项目引入了一个 composer 包,这个包是关于第三方登录的,https://github.com/xjflyttp/yii2-oauth
现在遇到一个问题,我需要重写 vendor 里面的获取微信 access_token 的方法,需要和全站的其他地方的 token 共享,所以需要存入 Redis,这就牵扯到了要改 vendor 里面的源码,一般情况下源码是不能动的,这个有办法不改动源码实现么?
文件路径是:vendor\xj\yii2-oauth\WeixinMpAuth.php
/**
* 获取公众号AccessToken
* @return MpAccessTokenResult
* @throws WeixinAccessTokenException
*/
public function getMpAccessToken()
{
try {
$result = $this->api($this->apiBaseUrl . '/cgi-bin/token', 'GET', [
'grant_type' => 'client_credential',
'appid' => $this->clientId,
'secret' => $this->clientSecret,
'openid' => $this->getOpenid(),
]);
return new MpAccessTokenResult($result);
} catch (Exception $e) {
throw new WeixinAccessTokenException($e->getMessage(), $e->getCode());
}
}
共 1 个回答
PHP学院的中学生
注册时间:2018-10-23
最后登录:2022-06-24
在线时长:146小时39分
最后登录:2022-06-24
在线时长:146小时39分
- 粉丝26
- 金钱2400
- 威望20
- 积分4060