Thinkphp Integration Series of SMS Verification Code, order notification

Source: Internet
Author: User

Now this message informs the flood of the age; If you don't have an SMS sign-up, you can't say you're a developer.

This verification code is not difficult to make, but if just contact is also a little unknown from where to start the confusion;

First, the concept;

1: Find a reliable SMS verification code platform, recommended the following used; The following Jong communication as an example; other platforms a truth;

Ali Big Fish: http://www.alidayu.com/service?spm=a3142.7802752.1.4.oAfDUZ&_t=2#sms

Jong Communication: http://www.yuntongxun.com/

2: Registration, login, certification, all nonsense; get account SID, AUTH TOKEN;

3: Create an application;

4: Add a template;

5: Audit pass; get template id; OK;

6: Complete? Think more, this is just reached the basic conditions can send verification code, and then download the official SDK;

The title is hung with thinkphp integrated SMS verification code; do not write thinkphp; must be sprayed to slag! There's no residue left!

All source code can be found in my open source project bjyadmin: http://git.oschina.net/shuaibai123/thinkphp-bjyadmin

Take my open source project as an example; put it on the/thinkphp/library/org/xb/rongcloud.class.php.

7: Add the function/application/common/common/function.php in the Public function library

/** *  send   Jong communication   Verification code  *  @param   int  $phone   Phone number  * @ param  int  $code    Verification codes  *  @return  boole        Whether to send success  */function send_sms_code ($phone, $code) {    //request address, format as follows, do not need to write https://      $serverIP = ' app.cloopen.com ';     //request Port     $ serverport= ' 8883 ';     //rest version number      $softVersion = ' 2013-12-26 ';     //Master Account      $accountSid =c (' Ronglian_account_sid ');     / /Master Account token     $accountToken =c (' Ronglian_account_token ');     //app ID      $appId =c (' ronglian_appid ');     $rest  = new \org\xb\ Rest ($serverIP, $serverPort, $softVersion);     $rest->setaccount ($accountSid, $ Accounttoken);    $rest->setappid ($appId);    //  send template sms      $result = $rest Sendtemplatesms ($phone, Array ($code, 5), 59939);     if ($result ==null)  {         return false;    }    if ($ result->statuscode!=0)  {        return  false;     }else{        return true;     }}

8: Fill in configuration item/application/common/conf/config.php with account SID, AUTH TOKEN, template ID

' Ronglian_account_sid ' = ' + ',//Jong Communication Master Account Accountsid ' Ronglian_account_token ' + ',//Jong Communication Master account TOKEN Accounttoken ' Ronglian_appid ' + ',//Jong communication app ID APPID

9: Call Function: Send_sms_code (' phone number ', ' Verification Code ');


I recently organized the Open source project is already integrated well, all this, only need in the configuration item in the blanks, can send a text message;

Children's shoes need to be able to directly git clone test: http://git.oschina.net/shuaibai123/thinkphp-bjyadmin

Thinkphp Integration Series of SMS Verification Code, order notification

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.