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