Who will receive the SMS verification code?

Source: Internet
Author: User
Tags sendmsg
Text message verification code who has an API on the website now has only one front-end page. could you tell me how to write PHP? I have never touched anyone before. if anyone can, add my QQ804135715 to solve this problem. I 'd like to be a master.


Reply to discussion (solution)

You haven't used the api provided by the text message service provider.
There should be a demo

The SMS verification code for www.yuntongxun.com is fast, with an average of about 8 seconds. The following are class files

 AccountSid = $ accountsid; $ this-> AccountToken = $ accounttoken; $ this-> AppId = $ appid; $ this-> TemplateId = $ tempid; $ this-> Batch = date ('ymdhis ', time ();}/*** send SMS */public function sendMsg ($ to, $ datas) {// splice the request body $ data = ""; for ($ I = 0; $ I
 
  
TemplateId. "', 'appid': '$ this-> appId', 'datas ':[". $ data. "]}"; // upper case sig parameter $ sig = strtoupper (md5 ($ this-> AccountSid. $ this-> AccountToken. $ this-> Batch); // Generate the request URL $ url = "https: // $ this-> ServerIP: $ this-> ServerPort/$ this-> SoftVersion/Accounts/$ this-> AccountSid/SMS/TemplateSMS? Sig = $ sig "; // Generate authorization: master account Id + English colon + timestamp. $ Authen = base64_encode ($ this-> AccountSid. ":". $ this-> Batch); // Generate the header $ header = array ("Accept: application/json", "Content-Type: application/json; charset = utf-8 ", "Authorization: $ authen"); // send a request $ result = $ this-> curl_post ($ url, $ body, $ header); $ datas = json_decode ($ result ); /* if ($ datas = FALSE) {$ datas = new stdClass (); $ datas-> statusCode = '20180101 '; $ datas-> statusMsg = 'return package body error';} * // reload the data if ($ dat As-> statusCode = 0) {$ datas-> TemplateSMS = $ datas-> templateSMS; unset ($ datas-> templateSMS);} return $ datas ;} /*** initiate HTTPS request */private function curl_post ($ url, $ data, $ header, $ post = 1) {// initialize curl $ ch = curl_init (); // parameter settings $ res = curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, FALSE ); curl_setopt ($ ch, CURLOPT_HEADER, 0 ); Curl_setopt ($ ch, CURLOPT_POST, $ post); if ($ post) curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header); $ result = curl_exec ($ ch); curl_close ($ ch); return $ result ;}} /*** application instance // primary account $ accountSid = 'xxxxxx'; // primary account Token $ accountToken = 'xxxxxx'; // application Id $ appId = 'xxxxxx '; // template Id $ templateId = 'xxxxxx'; $ Sms_yuntongxun = new Sms_yunton Gxun ($ accountSid, $ accountToken, $ appId, $ templateId); print_r ($ Sms_yuntongxun-> sendMsg ('123', array (13612345678, 'register a new user ', 15); */?>
 

Text message providers should have interfaces, just write them according to the demo they gave.

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.