mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2025-04-06 03:58:03 +08:00
修改基础代码
This commit is contained in:
parent
5ecafcd810
commit
d4a93b6d50
@ -128,21 +128,21 @@ class BasicWeChat
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置外部接口 AccessToken
|
* 设置外部接口 AccessToken
|
||||||
* @param string $access_token
|
* @param string $accessToken
|
||||||
* @throws \WeChat\Exceptions\LocalCacheException
|
* @throws \WeChat\Exceptions\LocalCacheException
|
||||||
* @author 高一平 <iam@gaoyiping.com>
|
* @author 高一平 <iam@gaoyiping.com>
|
||||||
*
|
*
|
||||||
* 当用户使用自己的缓存驱动时,直接实例化对象后可直接设置 AccessToekn
|
* 当用户使用自己的缓存驱动时,直接实例化对象后可直接设置 AccessToken
|
||||||
* - 多用于分布式项目时保持 AccessToken 统一
|
* - 多用于分布式项目时保持 AccessToken 统一
|
||||||
* - 使用此方法后就由用户来保证传入的 AccessToekn 为有效 AccessToekn
|
* - 使用此方法后就由用户来保证传入的 AccessToken 为有效 AccessToken
|
||||||
*/
|
*/
|
||||||
public function setAccessToken($access_token)
|
public function setAccessToken($accessToken)
|
||||||
{
|
{
|
||||||
if (!is_string($access_token)) {
|
if (!is_string($accessToken)) {
|
||||||
throw new InvalidArgumentException("Invalid AccessToken type, need string.");
|
throw new InvalidArgumentException("Invalid AccessToken type, need string.");
|
||||||
}
|
}
|
||||||
$cache = $this->config->get('appid') . '_access_token';
|
$cache = $this->config->get('appid') . '_access_token';
|
||||||
Tools::setCache($cache, $this->access_token = $access_token);
|
Tools::setCache($cache, $this->access_token = $accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,8 +169,7 @@ class BasicWeChat
|
|||||||
} catch (InvalidResponseException $exception) {
|
} catch (InvalidResponseException $exception) {
|
||||||
if (isset($this->currentMethod['method']) && empty($this->isTry)) {
|
if (isset($this->currentMethod['method']) && empty($this->isTry)) {
|
||||||
if (in_array($exception->getCode(), ['40014', '40001', '41001', '42001'])) {
|
if (in_array($exception->getCode(), ['40014', '40001', '41001', '42001'])) {
|
||||||
$this->delAccessToken();
|
[$this->delAccessToken(), $this->isTry = true];
|
||||||
$this->isTry = true;
|
|
||||||
return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']);
|
return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user