PHP发送 短信验证码
$phone = trim(input('phone',false)); if(strlen($phone) < 10){ $this->error("手机格式错误"); } $code_send_time = time() - session('code_send_time'); if($code_send_time < 60){ $temp_num = 60 - $code_send_time; $this->error("请稍等 ".$temp_num ." 秒"); }else{ session('code_send_time',time()); } $url = "http://inspection.ruijie.com.cn/api/sms/common/send"; $data = json_encode(["phone"=>$phone]); $curl = curl_init($url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json")); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); $resultone = curl_exec($curl); curl_close($curl); $resultone = json_decode($resultone,true); if(@$resultone['item']==true){ $this->success('发送成功'); }else{ $this->success($resultone['message']); }
标签:code,setopt,验证码,send,发送,time,curl,CURLOPT From: https://www.cnblogs.com/xhrs/p/16861419.html