dovechen/yii2-ihuyi

Yii2 ihuyi 短信 SDK

安装次数: 1,007

依赖: 0

建议: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

类型:yii2-extension

v1.0.3 2023-08-28 02:01 UTC

This package is auto-updated.

Last update: 2024-09-28 04:42:45 UTC


README

Yii2 ihuyi 短信 SDK

安装

安装此扩展的首选方法是使用 composer

运行

php composer.phar require --prefer-dist dovechen/yii2-ihuyi "*"

或者在你的 composer.json 文件的 require 部分添加

"dovechen/yii2-ihuyi": "*"

to

配置

要使用此扩展,你必须在应用配置中配置 Connection 类

return [
    //....
    'components' => [
        'ihuyi' => [
            'class' => 'dovechen\yii2\ihuyi\Ihuyi',
            // normal sms.
            'sms'  => [
                'appid'  => '',
                'apikey' => '',
            ],
            // international sms.
            'isms'  => [
                'appid'  => '',
                'apikey' => '',
            ],
            // voice sms.
            'vsms'  => [
                'appid'  => '',
                'apikey' => '',
            ],
            // voice notice sms.
            'vnsms'  => [
                'appid'  => '',
                'apikey' => '',
            ],
            // marketing sms.
            'msms'  => [
                'appid'  => '',
                'apikey' => '',
            ],
            // multimedia sms.
            'mms'  => [
                'appid'  => '',
                'apikey' => '',
            ],
        ],
    ]
];

使用

扩展安装完成后,只需在代码中通过

正常短信

// Send normal sms.
$sendResult = Yii::$app->ihuyi->sendSms('15395090543', 'Your code is 1123.');

// Get normal sms.
$smsNumInfo = Yii::$app->ihuyi->getSmsNum();

// Add normal sms template.
$smsTemplateInfo = Yii::$app->ihuyi->addSmsTemplate('Your code is【变量】');

国际短信

// Send international sms.
$sendResult = Yii::$app->ihuyi->sendInternational('+86 15395090543', 'Your code is 1123.');

// Get international sms.
$internationalNumInfo = Yii::$app->ihuyi->getInternationalNum();

语音短信

// Send voice sms.
$sendResult = Yii::$app->ihuyi->sendVoice('15395090543', '1123');

// Get voice sms.
$voiceNumInfo = Yii::$app->ihuyi->getVoiceNum();

语音通知短信

// Send voice notice sms.
$sendResult = Yii::$app->ihuyi->sendVoiceNotice('15395090543', 'Your code is 1123.');

// Get voice notice sms.
$voiceNoticeNumInfo = Yii::$app->ihuyi->getVoiceNoticeNum();

营销短信

// Send marketing sms.
$sendResult = Yii::$app->ihuyi->sendMarketing('15395090543,15395090544', 'Your code is 1123.');
$sendResult = Yii::$app->ihuyi->sendMarketing(['15395090543', '15395090544'], 'Your code is 1123.');

// Get marketing sms.
$marketingNumInfo = Yii::$app->ihuyi->getMarketingNum();

多媒体短信

// Send multimedia sms.
$sendResult = Yii::$app->ihuyi->sendMms('15395090543', 10048, 1001);
$sendResult = Yii::$app->ihuyi->sendMms('15395090543,15395090544', 10048, 1001);
$sendResult = Yii::$app->ihuyi->sendMms(['15395090543', '15395090544'], 10048, 1001);

// Get multimedia sms.
$multimediaNumInfo = Yii::$app->ihuyi->getMmsNum();

// Create multimedia sms.
$multimediaInfo = Yii::$app->ihuyi->createMms('New mutledia title', $zipFile);