PHP code example of beboc / sms-client

1. Go to this page and download the library: Download beboc/sms-client 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/ */

    

beboc / sms-client example snippets


use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\Null;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new Null($guzzle, $resp);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);

use Matthewbdaly\SMS\Drivers\Log;
use Matthewbdaly\SMS\Client;
use Psr\Log\LoggerInterface;

$driver = new Log($logger); // $logger should be an implementation of Psr\Log\LoggerInterface
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);


use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\RequestBin;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new RequestBin($guzzle, $resp, [
    'path' => 'MY_REQUESTBIN_PATH',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\Clockwork;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new Clockwork($guzzle, $resp, [
    'api_key' => 'MY_CLOCKWORK_API_KEY',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\Nexmo;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new Nexmo($guzzle, $resp, [
    'api_key' => 'MY_NEXMO_API_KEY',
    'api_secret' => 'MY_NEXMO_API_SECRET',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'from'    => 'Test User',
    'content' => 'Just testing',
];
$client->send($msg);

use Matthewbdaly\SMS\Client;
use Matthewbdaly\SMS\Drivers\Aws;

$config = [
    'api_key'    => 'foo',
    'api_secret' => 'bar',
    'api_region' => 'ap-southeast-2'
];
$driver = new Aws($config);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'from'    => 'Test User',
    'content' => 'Just testing',
];
$client->send($msg);

use Matthewbdaly\SMS\Client;
use Matthewbdaly\SMS\Drivers\Mail;
use Matthewbdaly\SMS\Contracts\Mailer;

$config = [
    'domain' => 'my.sms-gateway.com'
];
$driver = new Mail($config);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\TextLocal;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new TextLocal($guzzle, $resp, [
    'api_key' => 'MY_TEXTLOCAL_API_KEY',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'from'    => 'Test User',
    'content' => 'Just testing',
];
$client->send($msg);

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Matthewbdaly\SMS\Drivers\Twilio;
use Matthewbdaly\SMS\Client;

$guzzle = new GuzzleClient;
$resp = new Response;
$driver = new Twilio($guzzle, $resp, [
    'account_id' => 'MY_TWILIO_ACCOUNT_ID',
    'api_token' => 'MY_TWILIO_API_TOKEN',
]);
$client = new Client($driver);
$msg = [
    'to'      => '+44 01234 567890',
    'from'      => '+44 01234 567890',
    'content' => 'Just testing',
];
$client->send($msg);