Laravel frame access SMS platform for user registration SMS verification

Source: Internet
Author: User
Tags tojson

Today just contacted a SMS interface platform, Cloud communications third-party SMS provider. http://www.yuntongxun.com/

Then describe how to use the SMS platform to access their own projects.

First you have to register an account, and then according to the information provided, as an interface to access.

Write the account SID, Auth token, Rest URL, and other information into your code. It will be uploaded later by the sample code.

Then is the instantiation of the SMS class, the call inside the method is good, a lot of methods have been encapsulated, directly with the good.

Public Function sendsms (Request $request) {$m 3_result = new M3result ();        $phone = $request->input (' phone ', ');            if ($phone = = ") {$m 3_result->status = 1;            $m 3_result->message = ' mobile phone number cannot be empty ';        return $m 3_result->tojson ();        } $sendTemplateSMS = new sendtemplatesms ();        $code = ";        $charset = ' 1234567890 ';        $_len = strlen ($charset)-1;        for ($i =0; $i <6;++ $i) {$code. = $charset [Mt_rand (0,$_len)];        } $sendTemplateSMS->sendtemplatesms ($phone, Array ($code, 60), 1);        $deadline = Date ("Y-m-d h:i:s", Time () +60*60); if (Tempphone::where (' phone ', $phone)->first ()) {tempphone::where (' phone ', $phone)->update ([' code ' + = $code        , ' deadline ' = $deadline]);            }else{$tempPhone = new Tempphone ();            $tempPhone->phone= $phone;            $tempPhone->code= $code;            $tempPhone->deadline= $deadline; $tempPhone->sAve ();        } $m 3_result->status=0;        $m 3_result->message= ' send success ';    return $m 3_result->tojson (); }

This is the foreground for asynchronous authentication.

This is the table that stores the captcha temporarily.

Download the SMS Interface platform Tool class:

Laravel frame access SMS platform for user registration SMS verification

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.