PHP code example of alexeevdv / php-sms-smsru
1. Go to this page and download the library: Download alexeevdv/php-sms-smsru library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexeevdv / php-sms-smsru example snippets
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
}