From fed0e83057e33430bf9e981c82bdbb61675e1a3d Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 13 Nov 2018 09:40:49 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=AE=9D=E6=94=AF=E4=BB=98=E5=8F=8A=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- WeChat/Contracts/BasicAliPay.php | 2 +- WeChat/Contracts/BasicWeChat.php | 10 ++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index d13044c..3803ef2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /vendor /Cache /Test/cert -/composer.lock +/nbproject +/composer.lock \ No newline at end of file diff --git a/WeChat/Contracts/BasicAliPay.php b/WeChat/Contracts/BasicAliPay.php index 15534c3..36140ce 100644 --- a/WeChat/Contracts/BasicAliPay.php +++ b/WeChat/Contracts/BasicAliPay.php @@ -196,8 +196,8 @@ abstract class BasicAliPay protected function getResult($options) { $this->applyData($options); - $data = json_decode(Tools::get($this->gateway, $this->options->get()), true); $method = str_replace('.', '_', $this->options['method']) . '_response'; + $data = json_decode(Tools::get($this->gateway, $this->options->get()), true); if (!isset($data[$method]['code']) || $data[$method]['code'] !== '10000') { throw new \WeChat\Exceptions\InvalidResponseException( "Error: " . diff --git a/WeChat/Contracts/BasicWeChat.php b/WeChat/Contracts/BasicWeChat.php index 30bbc25..3dd4eb0 100644 --- a/WeChat/Contracts/BasicWeChat.php +++ b/WeChat/Contracts/BasicWeChat.php @@ -148,10 +148,12 @@ class BasicWeChat try { return Tools::json2arr(Tools::get($url)); } catch (InvalidResponseException $e) { - if (!$this->isTry && in_array($e->getCode(), ['40014', '40001', '41001', '42001'])) { - $this->delAccessToken(); - $this->isTry = true; - return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']); + if (isset($this->currentMethod['method']) && empty($this->isTry)) { + if (in_array($e->getCode(), ['40014', '40001', '41001', '42001'])) { + $this->delAccessToken(); + $this->isTry = true; + return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']); + } } throw new InvalidResponseException($e->getMessage(), $e->getCode()); }