Skip to content

Commit

Permalink
fix: NowcnGateway的key不存在时返回的不是json格式
Browse files Browse the repository at this point in the history
fix: NowcnGateway的请求返回没解析成json格式
  • Loading branch information
dsuzejian committed Aug 8, 2023
1 parent 5d27195 commit 08c7ec0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Gateways/NowcnGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class NowcnGateway extends Gateway

public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config)
{
if (!$config->get('key')) {
throw new GatewayErrorException("key not found", -2, []);
}
$params=[
'mobile' => $to->getNumber(),
'content' => $message->getContent($this),
Expand All @@ -26,6 +29,7 @@ public function send(PhoneNumberInterface $to, MessageInterface $message, Config
'apiType' => $config->get('api_type'),
];
$result = $this->get(self::ENDPOINT_URL, $params);
$result = is_string($result) ? json_decode($result, true) : $result;
if (self::SUCCESS_CODE != $result['code']) {
throw new GatewayErrorException($result['msg'], $result['code'], $result);
}
Expand Down

0 comments on commit 08c7ec0

Please sign in to comment.