欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

laravel 腾讯云短信

最编程 2024-05-07 18:22:28
...
public function tecentSms(Request $request) { $phone = $request->input("hiphone"); $appid = "1400617682";//SDK appid $appkey = "75c4537ce96a78e33ab1410a287084de";//SDK appkey $rand = rand(100000, 999999);//code $minute = 1000;//有效时间 $tempid = 1264814;//模板id $params = ["$rand"]; $sign = "郑自强学习和测试代码";//签名内容 try { $sender = new SmsSingleSender($appid, $appkey); $result = $sender->sendWithParam("86", $phone, $tempid, $params, $sign);//86为地区数字编号 $rsp = json_decode($result, true); if ($rsp['result'] == 0) { $rsp['code'] = '1'; $rsp['msg'] = $phone; Cache::put($phone, $rand, $minute);//放入缓存 return $rsp; } else { $rsp['code'] = '0'; return $rsp; } } catch (\Exception $e) { $rsp['code'] = '0'; return $rsp; } }