sscs/alidayu
Composer 安装命令:
composer require sscs/alidayu
包简介
阿里大鱼短信操作类封装
README 文档
README
阿里大鱼短信封装composer插件
Rely
Aliyun\Core; 你的命名空间里需要有阿里云的核心sdk,如果没有,这里推荐使用这个人写的。 lokielse/aliyun-open-api-core
参考操作SDK:
<?php namespace Myapp; use Config,Log; use Aliyun\Core as AliCore; use alidayu\Request\Dysmsapi\V20170525 as AliSMS; /** * * 阿里大鱼短信操作类 * * @author sscs <laosql@163.com> * * Timer 2017/7/13 * */ class SmsSDK { private $accessKeyId; private $accessKeySecret; private $product; private $domain; private $region; private $acsClient; /** * init */ public function __construct() { $this->accessKeyId = config('oss.sms.accessKeyId'); $this->accessKeySecret = config('oss.sms.accessKeySecret'); //短信API产品名 $this->product = config('oss.sms.product'); //短信API产品域名 $this->domain = config('oss.sms.domain'); //暂时不支持多Region $this->region = config('oss.sms.region'); // 设置参数 $regionIds = AliCore\Regions\EndpointConfig::getRegionIds(); $regionIds = array( $this->region ); $productDomains = array( new AliCore\Regions\ProductDomain($this->product, $this->domain) ); $endpoint = new AliCore\Regions\Endpoint($this->region, $regionIds, $productDomains); $endpoints = array( $endpoint ); AliCore\Regions\EndpointProvider::setEndpoints($endpoints); //初始化访问的acsCleint $profile = AliCore\Profile\DefaultProfile::getProfile($this->region, $this->accessKeyId, $this->accessKeySecret); $this->acsClient= new AliCore\DefaultAcsClient($profile); } /** * 短信发送 * * @param $phone 必填 短信接收号码 支持以逗号分隔的形式进行批量调用,批量上限为 * 20个手机号码,批量调用相对于单条调用及时性稍有延迟 * * @param $sms_signature 必填 短信签名 阿里云的签名名称,汉字 * @param $sms_code 必填 短信模板code * @param $array 选填 替换模板的变量,比如 array('name'=>'张竣升') * @param $out_id 选填 流水号ID * * @return bool */ public function send($phone,$sms_signature,$sms_code,$array,$out_id = '') { try { $request = new AliSMS\SendSmsRequest; $request->setPhoneNumbers($phone); $request->setSignName($sms_signature); $request->setTemplateCode($sms_code); if(count($array)) $request->setTemplateParam(json_encode($array)); if($out_id) $request->setOutId($out_id); //发起访问请求 $acsResponse = $this->acsClient->getAcsResponse($request); } catch (Exception $e) { Log::error('阿里大鱼短信服务错误(Try):'.$e.' -'.date('Y-m-d H:i:s',time())); } if($acsResponse->Code !== 'OK') { Log::error('阿里大鱼短信服务错误:'.$acsResponse->Message.' -'.date('Y-m-d H:i:s',time())); return false; } return true; } } 调用: $SmsSDK = new SmsSDK(); $phone = 152268xxxxx; $sms_signature = '张竣升测试'; $sms_code = 'SMS_7717xxx'; $array = array('name' => '张竣升','code'=>6661); $out_id = ''; $res = $SmsSDK->send($phone,$sms_signature,$sms_code,$array,$out_id = ''); dd($res); //true
sscs/alidayu 适用场景与选型建议
sscs/alidayu 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 176 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 07 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「阿�」 「大�」 「alidayu」 「阿�」 「短信」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sscs/alidayu 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sscs/alidayu 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sscs/alidayu 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
阿里短信-适用Laravel、Yii、Thinkphp等任何PHP项目...
阿里大于(鱼)API-SDK;适用任何PHP项目,包括Laravel、Yii、Thinkphp等...
阿里大鱼laravel5封装包,提供简单明确的调用方法
阿里大鱼短信平台
Simple and easy to use, a laravel package of alidayu.
Alidayu
统计信息
- 总下载量: 176
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-13