Skip to content

Commit

Permalink
调用时发现异常 (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
suguer committed Aug 8, 2023
1 parent 81d4dee commit 18aa3e1
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 18aa3e1

Please sign in to comment.