/** * @param MessageInterface|Message $message * @return mixed|void * @throws RuntimeException */ public function send(MessageInterface $message) { $config = $this->getSenderOptions(); $serviceURL = "http://letsads.com/api"; $body = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><request></request>'); $auth = $body->addChild('auth'); $auth->addChild('login', $config->getUsername()); $auth->addChild('password', $config->getPassword()); $messageXML = $body->addChild('message'); $messageXML->addChild('from', $config->getSender()); $messageXML->addChild('text', $message->getMessage()); $messageXML->addChild('recipient', $message->getRecipient()); $client = new Client(); $client->setMethod(Request::METHOD_POST); $client->setUri($serviceURL); $client->setRawBody($body->asXML()); $client->setOptions(['sslverifypeer' => false, 'sslallowselfsigned' => true]); try { $response = $client->send(); } catch (Client\Exception\RuntimeException $e) { throw new RuntimeException("Failed to send sms", null, $e); } try { $responseXML = new \SimpleXMLElement($response->getBody()); } catch (\Exception $e) { throw new RuntimeException("Cannot parse response", null, $e); } if ($responseXML->name === 'error') { throw new RuntimeException("LetsAds return error (" . $responseXML->description . ')'); } }
/** * @param MessageInterface $message * @return mixed|void * @throws RuntimeException */ public function send(MessageInterface $message) { $config = $this->getSenderOptions(); $serviceURL = "https://sys.sms-assistent.ru/api/v1/send_sms/plain?"; $queryURL = $serviceURL . http_build_query(['user' => $config->getUsername(), 'password' => $config->getPassword(), 'sender' => $config->getSender(), 'recipient' => preg_replace('/[^0-9]/', '', $message->getRecipient()), 'message' => $message->getMessage()]); $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); } if (floatval($response->getBody()) <= 0) { throw new RuntimeException("Failed to send sms"); } }
/** * @param MessageInterface $message * @return mixed|void * @throws RuntimeException */ public function send(MessageInterface $message) { $config = $this->getSenderOptions(); $serviceURL = "http://sms.ru/sms/send?"; $queryURL = $serviceURL . http_build_query(['login' => $config->getUsername(), 'password' => $config->getPassword(), 'to' => $message->getRecipient(), 'from' => $config->getSender(), 'text' => $message->getMessage(), 'partner_id' => 21871]); $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); } if (!$response or trim(current(explode("\n", $response))) !== "100") { throw new RuntimeException("Failed to send sms"); } }
/** * @param MessageInterface $message * @return mixed|void * @throws RuntimeException */ public function send(MessageInterface $message) { $config = $this->getSenderOptions(); $serviceURL = "http://smsc.ru/sys/send.php?"; $queryURL = $serviceURL . http_build_query(['login' => $config->getUsername(), 'psw' => $config->getPassword(), 'sender' => $config->getSender(), 'phones' => $message->getRecipient(), 'mes' => $message->getMessage(), 'fmt' => 3]); $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->getContent()); if (empty($responseData) or !isset($responseData->id)) { throw new RuntimeException("Failed to send sms"); } }
/** * @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"); } }
/** * @param MessageInterface $message * @return mixed|void * @throws RuntimeException */ public function send(MessageInterface $message) { $config = $this->getSenderOptions(); $serviceURL = "http://www.websms.ru/http_in5.asp?"; $queryURL = $serviceURL . http_build_query(['http_username' => $config->getUsername(), 'http_password' => $config->getPassword(), 'phone_list' => $message->getRecipient(), 'fromPhone' => $config->getSender(), 'message' => $message->getMessage()]); $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); } foreach (explode("\n", $response->getBody()) as $line) { $line = explode(" = ", $line); if (trim($line[0]) == "error_num" && trim($line[1]) != "OK") { throw new RuntimeException("Failed to send sms"); } } }
/** * @param MessageInterface $message * @return mixed|void * @throws RuntimeException */ public function send(MessageInterface $message) { $config = $this->getSenderOptions(); $serviceURL = "http://websms.by"; $queryURL = $serviceURL . http_build_query(['r' => 'api/msg_send', 'user' => $config->getUsername(), 'apikey' => $config->getPassword(), 'recipients' => $message->getRecipient(), 'sender' => $config->getSender(), 'message' => $message->getMessage()]); $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); } if ($response) { $responseData = @json_decode($response->getContent()); if (empty($responseData) or $responseData->status != "success") { if (isset($responseData->message)) { throw new RuntimeException("Failed to send sms: " . $responseData->message); } else { throw new RuntimeException("Failed to send sms"); } } } }