Skip to content

Commit

Permalink
Fixed #2716
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Jun 14, 2023
1 parent 7b1ada8 commit 7487ea7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Kernel/Traits/RespondXmlMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use EasyWeChat\Kernel\Support\Xml;
use function is_array;
use function is_callable;
use function is_string;
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use function time;
Expand Down Expand Up @@ -48,7 +49,7 @@ public function transformToReply(mixed $response, Message $message, ?Encryptor $
*/
protected function normalizeResponse(mixed $response): array
{
if (is_callable($response)) {
if (! is_string($response) && is_callable($response)) {
$response = $response();
}

Expand Down
6 changes: 3 additions & 3 deletions src/OfficialAccount/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public function getStableAccessToken(bool $force_refresh = false): string
'grant_type' => 'client_credential',
'appid' => $this->appId,
'secret' => $this->secret,
'force_refresh' => $force_refresh
'force_refresh' => $force_refresh,
],
]
)->toArray(false);

if (empty($response['access_token'])) {
throw new HttpException('Failed to get stable access_token: ' . json_encode($response, JSON_UNESCAPED_UNICODE));
throw new HttpException('Failed to get stable access_token: '.json_encode($response, JSON_UNESCAPED_UNICODE));
}

$this->cache->set($this->getKey(), $response['access_token'], intval($response['expires_in']));
Expand All @@ -143,7 +143,7 @@ public function getAccessToken(): string
)->toArray(false);

if (empty($response['access_token'])) {
throw new HttpException('Failed to get access_token: ' . json_encode($response, JSON_UNESCAPED_UNICODE));
throw new HttpException('Failed to get access_token: '.json_encode($response, JSON_UNESCAPED_UNICODE));
}

$this->cache->set($this->getKey(), $response['access_token'], intval($response['expires_in']));
Expand Down

1 comment on commit 7487ea7

@vercel
Copy link

@vercel vercel bot commented on 7487ea7 Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

easywechat – ./

easywechat-overtrue.vercel.app
easywechat-git-6x-overtrue.vercel.app
easywechat.vercel.app

Please sign in to comment.