httpClient=new Client([ 'http_errors' => false ]); $this->appid=config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.client_id'); $this->appkey=config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.client_secret'); } public function getAccessToken() { $access_token = Cache::get('baidu_access_token'); if (empty($access_token)) { $uri=$this->url."oauth/2.0/token?grant_type=client_credentials&client_id=$this->appid&client_secret=$this->appkey"; $curl = new CurlService(); $resopnse= $curl->get($uri); $result = json_decode($resopnse, true); Cache::put("wechat_access_token", $result['access_token'], 24*60*29); return $result['access_token']; } return $access_token; } public function health_code($image, $options=array()) { $data = array(); $data['image'] = base64_encode($image); $data = array_merge($data, $options); $curl = new CurlService(); $resopnse = $this->httpClient->post($this->url . "rest/2.0/ocr/v1/health_code",['form_params' => $data]); dd($resopnse->getBody()->getContents()); } }