In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how php can send CAPTCHA. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Php to achieve the function of sending CAPTCHA: 1, create a good HTML and js files; 2, create a "Msm.php" file, the content is "public function sendmsm () {...}"; 3, send a HTTP request through CURL.
This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer
How does php achieve the function of sending CAPTCHA?
PHP implements sending SMS verification code:
1. Html code
Mobile phone number: CAPTCHA: get CAPTCHA
II. Js code
/ * send verification code * @ return {[type]} [description] * / function get_svg () {var phone = $("input [name = 'telephone']") .val (); if (! (/ ^ 1 [34578]\ d {9} $/ .test (phone) {layer.msg ("Please enter your cell phone number correctly!") ; return false;} var url = "/ msm/sendmsm/phone/" + phone;$.get (url, function (resdata) {console.log (resdata); layer.msg (resdata.data); if (resdata.type = = 1) {$(".code _ btn"). Attr ('onclick', "return false;"); listion_sendmsm ();}) return false;} function listion_sendmsm () {var time = 61 SetTime = setInterval (function () {if (time $conf ['msm_appkey'],' password' = > $conf ['msm_secretkey'],' msg' = > urlencode ($content), 'phone' = > $telephone,'report' = > true); $result = $this- > curlPost ("http://smssh2.253.com/msg/send/json", $postArr); $json = json_decode ($result); if ($json-> code! = 0) {return false;} else {return true }} / * send HTTP request via CURL * @ param string $url / / request URL * @ param array $postFields / / request parameters * @ return mixed * * / private function curlPost ($url,$postFields) {$postFields = json_encode ($postFields); $ch = curl_init (); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HTTPHEADER, array ('Content-Type: application/json) Charset=utf-8' / / json version requires Content-Type: application/json;); curl_setopt ($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postFields); curl_setopt ($ch, CURLOPT_TIMEOUT,60); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0) $ret = curl_exec ($ch); if (false = = $ret) {$result = curl_error ($ch);} else {$rsp = curl_getinfo ($ch, CURLINFO_HTTP_CODE); if (200! = $rsp) {$result = "request status". $rsp. "". Curl_error ($ch);} else {$result = $ret;}} curl_close ($ch); return $result;}
Thank you for reading! This is the end of this article on "how php can send CAPTCHA". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.