0) { // 匹配关键字 $keyword = array(); $sql = ""; // 去除匹配结果数组 foreach ($image_res["result"] as $result) { // 筛选置信值大于0.5的结果 if ($result["score"] >= 0.5) { array_push($keyword, '%' . $result["keyword"] . '%'); // 拼接模糊查询语句 $sql = $sql . " or name like ?"; } } // 如果筛选结果大于0处理 if (count($keyword) > 0) { $sql = "select * from garbage where" . substr($sql, 3); info("查询sql" . $sql); $garbage_result = getGarbageQuery($sql, $keyword); json_res(json_encode(array("img_parse" => true, "query" => true, "img_res" => $image_res, "result" => $garbage_result->getGarbageObjArray()), JSON_UNESCAPED_UNICODE)); } else { json_res(json_encode(array("img_parse" => true, "img_res" => $image_res))); } } else { json_res(json_encode(array("img_parse" => false))); } } // 查询token $token_result = new class() extends AbstractTokenQuery { public function bind_param(mysqli_stmt $stmt, array $param) { } }; DbUtil::query("select * from api_token limit 0,1", $token_result); // toekn如果失效,则更新token if (strtotime(date(default_format)) >= strtotime($token_result->getToken()->getEndTime())) { info("token失效了,更新token"); $updateToken = new BaiduAiRequest("https://aip.baidubce.com/oauth/2.0/token"); $updateToken->request_token(); DbUtil::query("select * from api_token limit 0,1", $token_result); } //获取图片参数 if (isset($_POST["image"])) { // 请求通用物体和场景识别高级版接口 $image_req = new BaiduAiRequest("https://aip.baidubce.com/rest/2.0/image-classify/v2/advanced_general"); // 获取解析结果 $image_res = $image_req->request_with_param(array("access_token" => $token_result->getToken()->getAccessToken(), "image" => $_POST["image"])); query_waste_soring($image_res); } else if ($_FILES["file"]["error"] > 0) { json_res(<<request_with_param(array("access_token" => $token_result->getToken()->getAccessToken(), "image" => $image)); query_waste_soring($image_res); } else { json_res(<<