ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ public function sendcode(Request $request) { $message = ""; $phonenum = $request->param('phonenum'); $phone = Db::table('sbh_homeuser')->where(['phonenum' => $phonenum])->find(); if ($phone) { return json("exist"); } else { $count = str_pad(mt_rand(0, 999999), 6, "0", STR_PAD_BOTH); $host = "http://yzx.market.alicloudapi.com"; $path = "/yzx/sendSms"; $method = "POST"; $appcode = "4e9be4cb5a6f4a7fb383e53f2c7ee8ca"; $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); $querys = "mobile=$phonenum&param=code:$count&tpl_id=TP1802031"; $bodys = ""; $url = $host . $path . "?" . $querys; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); if (1 == strpos("$" . $host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } $result = curl_exec($curl); $result = json_decode($result, true); if ($result['return_code'] == 0000) { Cache::set('code', $count, 7200 * 12); return json('success'); } else { return json('error'); } } } ~~~