$number, "format" => "json", "message" => $message, ]; $postJson = json_encode($postData); curl_setopt_array($curl, [ CURLOPT_URL => 'https://api.smsapi.com/sms.do', CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postJson, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Accept: application/json', 'Authorization: Bearer ' . $apiToken, ], ]); $response = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); logNewMessage(LOG_DEBUG, 'SMS gateway response: ' . $response); $responseJson = json_decode($response, true); if (($httpCode !== 200) || isset($responseJson['error'])) { logNewMessage(LOG_ERR, 'Unable to send SMS: ' . $response); $message = $responseJson['message'] ?? $responseJson['list'][0]['error'] ?? ''; throw new LAMException(null, $message); } } /** * @inheritDoc */ public function usesApiToken(): bool { return true; } /** * @inheritDoc */ public function usesApiKey(): bool { return false; } /** * @inheritDoc */ public function usesAccountId(): bool { return false; } /** * @inheritDoc */ public function usesFrom(): bool { return false; } /** * @inheritDoc */ public function usesRegion(): bool { return false; } /** * @inheritDoc */ public function usesSubject(): bool { return false; } }