Home > php教程 > php手册 > 阿里大鱼API接口(短信接口)Thinkphp专版范例

阿里大鱼API接口(短信接口)Thinkphp专版范例

WBOY
Release: 2016-06-07 11:35:21
Original
1598 people have browsed it

阿里大鱼API接口(短信接口)Thinkphp专版范例

鉴于多数用户咨询Thinkphp使用方法,特此另外新增Thinkphp专版
原版地址:http://www.thinkphp.cn/code/1749.html

提供方官网:http://www.alidayu.com/

源码地址:
http://flc.ren/2016/02/452.html
https://code.csdn.net/flc1125/alidayu(原版)
https://code.csdn.net/flc1125/alidayu/tree/release/thinkphp(Thinkphp专版源码)

配置说明:
文件`/Application/Common/Conf/config.php`定义`AlidayuAppKey`和`AlidayuAppSecret`即可。获取,请参考官网!

使用说明:<?php <br /> /**<br>  * 阿里大鱼API接口(短信接口)Thinkphp专版范例<br>  *<br>  * @author Flc <br>  * @link http://flc.ren <br>  * @link https://code.csdn.net/flc1125/alidayu<br>  */<br> namespace Home\Controller;<br> <br> use Think\Controller;<br> use Alidayu\AlidayuClient as Client;<br> use Alidayu\Request\SmsNumSend;<br> <br> class IndexController extends Controller<br> {<br>     /**<br>      * 阿里大鱼demo<br>      * @return [type] [description]<br>      */<br>     public function index()<br>     {<br>         $client  = new Client;<br>         $request = new SmsNumSend;<br> <br>         // 短信内容参数<br>         $smsParams = [<br>             'code'    => $this->randString(),<br>             'product' => '测试的'<br>         ];<br> <br>         // 设置请求参数<br>         $req = $request->setSmsTemplateCode('SMS_5053601')<br>             ->setRecNum('13312341234')<br>             ->setSmsParam(json_encode($smsParams))<br>             ->setSmsFreeSignName('活动验证')<br>             ->setSmsType('normal')<br>             ->setExtend('demo');<br> <br>         print_r($client->execute($req));<br>     }<br> <br>     /**<br>      * 获取随机位数数字<br>      * @param  integer $len 长度<br>      * @return string       <br>      */<br>     protected static function randString($len = 6)<br>     {<br>         $chars = str_repeat('0123456789', $len);<br>         $chars = str_shuffle($chars);<br>         $str   = substr($chars, 0, $len);<br>         return $str;<br>     }<br> }<br> ?>其他说明:
目前仅开发短信相关功能,如需拓展,请在`/ThinkPHP/Library/Alidayu/Request/`目录下新增类,以开发更多功能接口!
开发文档参考网址:http://open.taobao.com/doc2/apiDetail.htm?spm=0.0.0.0.pjxLXY&apiId=25450

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template