mocean/yii-mocean

Mocean API for Yii 框架

v2.0.0 2019-06-25 03:55 UTC

This package is auto-updated.

Last update: 2024-09-29 05:28:06 UTC


README

Latest Stable Version Build Status StyleCI License Total Downloads

Yii Mocean API 集成

安装

要安装库,请在终端运行以下命令

composer require mocean/yii-mocean

在配置文件中设置配置

'components' => [
    'mocean' => [
        'class' => 'YiiMocean\MoceanServiceProvider',
        'defaults' => 'main',
        'accounts' => [ //define your account here
            'main' => [
                'api_key' => 'mainAccountApiKey',
                'api_secret' => 'mainAccountApiSecret'
            ],
            'secondary' => [ //if you have more then one account
                'api_key' => 'secondaryAccountApiKey',
                'api_secret' => 'secondaryAccountApiSecret'
            ]
        ],
    ],
]

用法

发送短信

//will be using the account defined in defaults
//see below if you have multiple accounts
Yii::$app->mocean->message()->send([
    'mocean-to' => '60123456789',
    'mocean-from' => 'MOCEAN',
    'mocean-text' => 'Hello World'
])

如果您在配置中定义了多个账户

Yii::$app->mocean->using('secondary')->message()->send(...);
Yii::$app->mocean->using('third')->message()->send(...);

许可

Laravel Mocean 使用的是 MIT 许可协议