/** * @param MessageInterface $message * @return mixed|void * @throws RuntimeException */ public function send(MessageInterface $message) { $config = $this->getSenderOptions(); $serviceURL = "http://api.rocketsms.by/simple/send?"; $queryURL = $serviceURL . http_build_query(['username' => $config->getUsername(), 'password' => $config->getPassword(), 'phone' => $message->getRecipient(), 'text' => $message->getMessage(), 'priority' => $message->isPrioritized()]); $client = new Client(); $client->setUri($queryURL); $client->setOptions(['sslverifypeer' => false, 'sslallowselfsigned' => true]); try { $response = $client->send(); } catch (Client\Exception\RuntimeException $e) { throw new RuntimeException("Failed to send sms", null, $e); } $responseData = @json_decode($response->getBody()); if (empty($responseData) or !isset($responseData->id)) { throw new RuntimeException("Failed to send sms"); } }