PHP code example of simialbi / yii2-websms-com

1. Go to this page and download the library: Download simialbi/yii2-websms-com 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/ */

    

simialbi / yii2-websms-com example snippets


return [
    // [...]
    'components' => [
        'sms' => [
            'class' => 'simialbi\yii2\websms\Connection',
            'baseUrl' => 'https://api.websms.com',
            'token' => '<your api token>',
            'sendUrl' => '/rest/smsmessaging/simple'
        ]
    ]
];


 /** @var \simialbi\yii2\websms\Connection $sms */
$sms = Yii::$app->get('sms', true);
$message = $sms->createMessage();
$message
    ->id('my-test-id-' . uniqid())
    ->category($message::CATEGORY_INFORMATIONAL)
    ->content("This is a test\nwith multpile lines")
    ->type($message::MESSAGE_TYPE_TEXT)
    ->addRecipient('4367612345678');
$response = $message->send();

if ($response->isOk) {
    echo 'success';
} else {
    echo 'failure';
}