PHP code example of dyce / osms

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

    

dyce / osms example snippets








use \Osms\Osms;

$config = array(
    'clientId' => 'your_client_id',
    'clientSecret' => 'your_client_secret'
);

$osms = new Osms($config);

// retrieve an access token
$response = $osms->getTokenFromConsumerKey();

if (!empty($response['access_token'])) {
    $senderAddress = 'tel:+22500000000';
    $receiverAddress = 'tel:+22500000000';
    $message = 'Hello World!';
    $senderName = 'Optimus Prime';

    $osms->sendSMS($senderAddress, $receiverAddress, $message, $senderName);
} else {
    // error
}



use \Osms\Osms;

$config = array(
    'token' => 'your_access_token'
);

$osms = new Osms($config);

$senderAddress = 'tel:+22500000000';
$receiverAddress = 'tel:+22500000000';
$message = 'Hello World!';
$senderName = 'Optimus Prime';

$osms->sendSMS($senderAddress, $receiverAddress, $message, $senderName);

$osms = new Osms();
$osms->setVerifyPeerSSL(false);