定制 demmonico/yii2-sms 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

demmonico/yii2-sms

Composer 安装命令:

composer require demmonico/yii2-sms

包简介

Yii2 extension which allow send sms using multiply providers. Now available Nexmo provider

README 文档

README

#Yii2 component - Sms Sender ##Description Yii2 component which allow simple send sms using multiply providers. Switching between providers supports using yii config file (better)

##Configure ###Common params

return [
    //...
    'components' => [
        //...
        'sms' => [
            'class' => 'demmonico\sms\Sender',
            'senderNumber' => 'name' or 'number',
            'provider' => [
                'class' => 'demmonico\sms\Nexmo',
                'apiKey' => '***',
                'apiSecret' => '***',
            ],
        ],
    ],
];

or DI

$component = \Yii::createObject('demmonico\sms\Nexmo', [
    [
        'class' => 'demmonico\sms\Sender',
        'senderNumber' => 'name' or 'number',
        'provider' => [
            'class' => 'demmonico\sms\Nexmo',
            'apiKey' => '***',
            'apiSecret' => '***',
        ],
    ],
]);

or using config component's bootstrap method (see https://github.com/demmonico/yii2-config)

in config file

return [
    //...
    'components' => [
        //...
        'sms' => [
            'class' => 'demmonico\sms\Sender',
            'senderNumber' => 'name' or 'number',
            'provider' => [
                'class' => 'demmonico\sms\Nexmo',
                'apiKey' => [
                    'component' => 'config',
                    'sms.Nexmo.apiKey',
                ],
                'apiSecret' => [
                    'component' => 'config',
                    'sms.Nexmo.apiSecret',
                ],
            ],
        ],
    ],
];

and in local params file

return [
    //...
    'sms.Nexmo.apiKey' => '******',
    'sms.Nexmo.apiSecret' => '******',
];

Now available Nexmo provider only. But you can add any external class with your custom provider. New providers can be added by creating class, which will implements demmonico\sms\SmsProviderInterface and extends (optional) demmonico\sms\BaseProvider.

###Debug params For debug you can use redirect option and dummy option. They can use separately or together. If redirect option redirectNumber is set then all messages will be send to this number. If dummy option dummyNumbers is set and field $to matches to any of dummyNumbers elements then process send will be skip and all sms fields will be logged

return [
    //...
    'components' => [
        //...
        'sms' => [
            //...
            'debug' => [
                'redirectNumber' => 'number',
                'dummyNumbers' => [
                    'number',
                    //...
                ],
            ],
        ],
    ],
];

##Usage ###Send sms

Yii::$app->sms->sendSms('Hello, world!', 'number');

or

Yii::$app->sms->sendSms('Hello, world!', 'recipientNumber', 'senderNumber');

Numbers must be in E.164 format. Method returns number (integer) of sent sms.

###Get account balance

Yii::$app->sms->getBalance();

Method returns balance value (float).

###Get account numbers

Yii::$app->sms->getNumbers();

Method returns array of numbers which are associate with account.

统计信息

  • 总下载量: 100
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固