Skip to content

vicens/alidayu-for-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads License

阿里云通信(阿里大于) For Laravel

阿里大于,是阿里通信旗下优质便捷的云通信服务平台,整合了三大运营商的通信能力,为开发者提供简洁易用的短信/语音API,三网合一通道,按需付费。阿里集团技术保障,实时、稳定、到达率高!

阿里云通信官网: https://dayu.aliyun.com

阿里云通信API文档: https://api.alidayu.com/doc2/apiList.htm

阿里云通信SDK: http://github.com/vicens/alidayu

环境要求

安装

composer require vicens/alidayu-for-laravel

使用

Laravel5.5以下需要注册服务提供者

config/app.phpprovider数组中, 添加\Vicens\AlidayuForLaravel\Providers\AlidayuServiceProvider:

'providers' => [
    // Other service providers...
    \Vicens\AlidayuForLaravel\Providers\AlidayuServiceProvider::class
]

设置配置

config/services.php中,添加配置

return [
    // other service config
    'alidayu' => [
        'appKey' => '23356838',
        'appSecret' => '254fee5fbabe2e01be04581d855c9af3',
        'sandbox' => false
    ]
];

调用API

use Vicens\Alidayu\Alidayu;
// 发送短信通知
$sms = Alidayu::sms($recNum, $smsTemplateCode, $smsFreeSignName, $smsParam, $extend);
// 发送请求并返回响应
$response = $sms->send();

if ($response->success()) {
    // 接口返回成功
    print_r($response->getData());
} else {
    // 接口返回错误
    echo $response->getError();
}

已支持的接口列表