fastwhale/yii2-ihuyi

Yii2 ihuyi短信SDK

安装: 39

依赖: 0

建议: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:yii2-extension

v1.0.5 2023-08-31 09:17 UTC

This package is auto-updated.

Last update: 2024-09-30 02:00:07 UTC


README

Yii2 ihuyi短信SDK

安装

安装此扩展的首选方法是通过Composer

运行以下命令之一

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

或者将以下内容添加到你的composer.json文件的require部分。

"fastwhale/yii2-ihuyi": "*"

配置

要使用此扩展,您必须配置应用配置中的Connection类

return [
    //....
    'components' => [
        'ihuyi' => [
            'class' => 'fastwhale\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);