PHP code example of ozerich / yii2-rocketsms

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

    

ozerich / yii2-rocketsms example snippets


    'components' => [
        'sms' => [
            'class' => 'blakit\rocketsms\RocketSms',
            'login' => 'your_login',
            'password' => 'your_password'
        ]
    ]

try {
    $response = \Yii::$app->sms->send('+375296000000', 'Test Message');
    echo 'SMS sent, message ID is ' . $response->getMessageId();
} catch (ErrorResponseException $exception) {
    echo 'Error sending SMS: ' . $exception->getError();
} catch (InvalidCredentialsException $exception) {
    echo 'RocketSMS credentials are invalid';
}

try {
    $response = \Yii::$app->sms->balance();
    echo 'Your balance: ' . $response->getBalance() . 'BYN, ' . $response->getCredits() . ' SMS';
} catch (InvalidCredentialsException $exception) {
    echo 'RocketSMS credentials are invalid';
}

try {
    $response = \Yii::$app->sms->status('MESSAGE_ID');
    echo 'Message status: ' . $response->getStatus();
} catch (ErrorResponseException $exception) {
    echo 'Message not found';
} catch (InvalidCredentialsException $exception) {
    echo 'RocketSMS credentials are invalid';
}

	php composer.phar