toArray(); $insert_arr = []; $new_arr = []; foreach ($mobile_arr as $mobile){ if(strlen($mobile) == 11){ $result = $this->getResult($mobile); $result = json_decode($result); if(!empty($result) && $result->code == 200000){ $new_arr['mobile'] = $mobile; $new_arr['status'] = $result->data[0]->status; $new_arr['result'] = $result; $new_arr['created_at'] = date("Y-m-d H:i:s"); $new_arr['updated_at'] = date("Y-m-d H:i:s"); $insert_arr[] = $new_arr; } } } CheckMobiles::insert($insert_arr); return true; } catch (\Exception $e) { return false; } } public function getResult($mobile){ $host = "http://ali.market.alicloudapi.com"; $path = "/open/unn/batch-ucheck"; $method = "POST"; $appcode = config("aliyun.appcode"); $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); $querys = "mobiles=".$mobile; $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); return $result; } }