alexeevdv/php-sms-smsru

0.1.0 2020-06-01 12:16 UTC

This package is auto-updated.

Last update: 2024-10-29 06:05:50 UTC


README

Build Status codecov PHP 7.1 PHP 7.2 PHP 7.3 PHP 7.4

PHP package for sending SMS messages via sms.ru provider

Usage

use alexeevdv\Sms\SmsRu\Exception\Exception as SmsRuException;
use alexeevdv\Sms\SmsRu\PhoneNumber;
use alexeevdv\Sms\SmsRu\Provider;

$httpClient = new Psr18CompatibleHttpClient();
$requestFactory = new Psr17CompatibleRequestFactory();

$provider = new Provider('Your API key', $httpClient, $requestFactory);
try {
   $messageId = $provider->sendMessage(new PhoneNumber('+1-234-567-89-10'), 'Hello!');
} catch (SmsRuException $e) {
   // Message is not sent
}