PHP code example of mediumart / orange-sms

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

    

mediumart / orange-sms example snippets


use Mediumart\Orange\SMS\SMS;
use Mediumart\Orange\SMS\Http\SMSClient;

/**
* if you already have a valid access token
* */
$client = SMSClient::getInstance('<your_access_token>');

// OR

/**
* directly using <client_id> and <client_secret>
* */
$client = SMSClient::getInstance('<client_id>', '<client_secret>');

$sms = new SMS($client);

// prepare and send an sms in a fluent way
$sms->message('Hello, my dear...')
    ->from('+237690000000')
    ->to('+237670000000')
    ->send();

// sending SMS.
$response = $sms->to('+237670000000')
                ->from('+237690000000', <'optional_sender_name>')
                ->message('Hello, world!')
                ->send();

// checking your balance(remaining sms units)
// with optional country code filter ie: CIV
$response = $sms->balance('<country_code>');

// checking SMS orders history
// with optional country code filter ie: CMR
$response = $sms->ordersHistory('<country_code>');

// checking SMS statistics
// with optional country code filter
// and optional appID filter
$response = $sms->statistics('<country_code>', '<app_id>');

// setting the SMS DR notification endpoint
// '<your_backend_notification_url>' $url
// '<sender address>' $sender = '+237690000000'
$response = $sms->setDeliveryReceiptNotificationUrl($url, $sender);

// checking the SMS DR notification endpoint
// '<your_last_registered_endpoint_ID>' $id
$response = $sms->checkDeliveryReceiptNotificationUrl($id);

// delete the SMS DR notification endpoint
// '<last_registered_endpoint_ID>' $id
// '<sender address>' $sender = '+237690000000'
$response = $sms->deleteDeliveryReceiptNotificationUrl($id, $sender);


use Mediumart\Orange\SMS\Http\SMSClient;

$client = SMSClient::getInstance('<client_id>', '<client_secret>');

// get the token
$token = $client->getToken();

// get the token lifetime in seconds
$tokenExpiresIn = $client->getTokenExpiresIn();

$response = SMSClient::authorize('<client_id>', '<client_secret>');

[
 "token_type" => "Bearer",
 "access_token" => "i6m2iIcY0SodWSe...L3ojAXXrH",
 "expires_in" => "7776000"
]

\Mediumart\Orange\SMS\Http\SMSClientRequest::verify(false);