src/Service/Tencent/OCRManager.php
protected function request($url, $images, array $options = [], $requestType = false)
    {
        $http = (new Http)->setHeaders([
            'Authorization' => $this->authorization->getAuthorization()
        ]);

        //腾讯 OCR 识别只支持单个图片
        $image = is_array($images) ? $images[0] : $images;

        //腾讯 OCR 识别时,部分接口的请求参数为 ret_image/url_list 部分又为 image/url --Fuck
        $urlName = $requestType ? 'url_list' : 'url';

        if (FileConverter::isUrl($image)) {
            $isurl = true;
        } else {
            $isurl = false;
            $multiparts['image'][] = $image;
        }

        $options = $this->appendAppIdAndBucketIfEmpty($options);

        try {
            if ($isurl) {
                $response = $http->json($url, array_merge($options, [$urlName => $image]));
            } else {
                $response = $http->upload($url, $multiparts, $options);
            }
        } catch (\GuzzleHttp\Exception\ClientException $e) {
            if ($e->hasResponse()) {
                $response = $e->getResponse();
            }
        }

        return $http->parseJson($response);
    }
protected function request($url, $images, array $options = [], $requestType = false)
    {
        $http = (new Http)->setHeaders([
            'Authorization' => $this->authorization->getAuthorization()
        ]);

        //腾讯 OCR 识别只支持单个图片
        $image = is_array($images) ? $images[0] : $images;

        //腾讯 OCR 识别时,部分接口的请求参数为 ret_image/url_list 部分又为 image/url --Fuck
        $urlName = $requestType ? 'url_list' : 'url';

        if (FileConverter::isUrl($image)) {
            $isurl = true;
        } else {
            $isurl = false;
            $multiparts['image'][] = $image;
        }

        $options = $this->appendAppIdAndBucketIfEmpty($options);

        try {
            if ($isurl) {
                $response = $http->json($url, array_merge($options, [$urlName => $image]));
            } else {
                $response = $http->upload($url, $multiparts, $options);
            }
        } catch (\GuzzleHttp\Exception\ClientException $e) {
            if ($e->hasResponse()) {
                $response = $e->getResponse();
            }
        }

        return $http->parseJson($response);
    }
Send a Http Request

@param  string $url
@param  string|\SplFileInfo $images
@param  array  $options

@return \Psr\Http\Message\ResponseInterface