Example of Alibaba big fish API interface (SMS Interface) Thinkphp Special Edition

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.