PHP code example of nnrudakov / yii2-sms

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

    

nnrudakov / yii2-sms example snippets


...
    'components' => [
        'sms' => [
            'class' => nnrudakov\sms\Sms::class,
                'services' => [
                    'beeline' => [
                        'class'    => nnrudakov\sms\services\beeline\Beeline::class,
                        'user'     => '',
                        'password' => ''
                    ]
                ]
        ],
        ...
    ],
...

...
    'components' => [
        'i18n' => [
            'translations' => [
                'sms' => [ // must be the same name
                    'class'            => yii\i18n\PhpMessageSource::class,
                    'basePath'         => '@app/messages',
                    'sourceLanguage'   => 'ru',
                    'forceTranslation' => true
                ],
            ],
        ],
        ...
    ],
...

 $service = Yii::$app->sms->getService('beeline');
 $service->send(['+7905XXXXXXX'], 'message');
 

 $service->hasErrors();
 

 $service->getErrors();
 

 $service->getErrors('+7905XXXXXXX');
 

...
    'beeline' => [
        'class'    => nnrudakov\sms\services\beeline\Beeline::class,
        'user'     => 'beeline_user',
        'password' => 'beeline_password'
    ]
...