Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn the Thinkphp Special Edition example of Alibaba big fish API interface (SMS interface ).
In view of the usage of Thinkphp, most users are advised to add Thinkphp special edition.
Address: http://www.thinkphp1.cn/code/1749.html
Official Website of the provider: http://www.alidayu.com/
Source Code address:
Http://flc.ren/2016/02/452.html
Https://code.csdn.net/flc1125/alidayu (original)
Https://code.csdn.net/flc1125/alidayu/tree/release/thinkphp (Thinkphp pro source code)
Configuration instructions:
The '/Application/Common/Conf/config. php' file defines 'alidayuappkey' and 'alidayuappsecret. For more information, see the official website!
Instructions for use:
/**
* Example of Thinkphp special edition of Alibaba big fish API interface (SMS Interface)
*
* @ Author Flc <23:18:10>
* @ Link http://flc.ren
* @ Link https://code.csdn.net/flc1125/alidayu
*/
Namespace Home \ Controller;
Use Think \ Controller;
Use Alidayu \ AlidayuClient as Client;
Use Alidayu \ Request \ SmsNumSend;
Class IndexController extends Controller
{
/**
* Alibaba big fish demo
* @ Return [type] [description]
*/
Public function index ()
{
$ Client = new Client;
$ Request = new SmsNumSend;
// SMS content parameters
$ SmsParams = [
'Code' => $ this-> randString (),
'Product' => 'Tested'
];
// Set Request Parameters
$ Req = $ request-> setSmsTemplateCode ('sms _ 000000 ')
-> SetRecNum ('20140901 ')
-> SetSmsParam (json_encode ($ smsParams ))
-> SetSmsFreeSignName ('activity verification ')
-> SetSmsType ('normal ')
-> SetExtend ('Demo ');
Print_r ($ client-> execute ($ req ));
}
/**
* Obtain random digits
* @ Param integer $ len Length
* @ Return string
*/
Protected static function randString ($ len = 6)
{
$ Chars = str_repeat ('20140901', $ len );
$ Chars = str_shuffle ($ chars );
$ Str = substr ($ chars, 0, $ len );
Return $ str;
}
}
?>
Other Instructions:
Currently, only SMS-related functions are developed. To expand the function, add classes in the '/ThinkPHP/Library/Alidayu/Request/' directory to develop more interfaces!
Development document reference URL: http://open.taobao.com/doc2/apiDetail.htm? Spm = 0.0.0.0.pjxLXY & apiId = 25450
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB