client = new AipOcr($appId, $apiKey, $secretKey); } public function posOCRByUrl($imgUrl){ // 如果有可选参数 $options = array(); $options["language_type"] = "CHN_ENG"; $options["detect_direction"] = "true"; $options["detect_language"] = "true"; $options["probability"] = "true"; // 带参数调用通用文字识别, 图片参数为远程url图片 $postResp = $this->client->basicGeneralUrl($imgUrl, $options); if ($postResp['error_code'] > 0) { return CommonTool::failCodeResult($postResp['error_code'], $postResp['error_msg']); } return CommonTool::successResult(array( 'direction' => $postResp['direction'], 'wordsResultNum' => $postResp['words_result_num'], 'wordsResult' => $postResp['words_result'] )); } }