如何正确配置Guzzle从其他服务器下载zip文件

时间:2019-02-22 14:36:33

标签: php http-status-code-400 guzzle6

此功能用于下载.zip文件

function download($url, $debug = false)
{
    $client = new Client([
        'connect_timeout' => 10,
        'timeout' => 60.0,
        'debug' => $debug
    ]);

    $response = $client->request('GET', $url);
    try {
        if ($response->getStatusCode() == 200) {
            return $response->getBody()->getContents();
        }

    } catch (RequestException $e) {
        //var_dump($response->getBody()->getContents());
        $txt = json_encode(['log_error' => $e->getResponse(), 'response' => $response->getBody()->getContents(), 'url' => $url]);
        file_put_contents(storage_path() . '/logs-etiquetas/log-' . microtime(true) . '-' . auth()->user()->company_id . '.txt', $txt);
    }
    return false;
}

我在下面遇到错误

  

production_ERROR:客户端错误:GET https: //api.mercadolibre.com/shipment_labels? shipment_ids = 27868452659,27864682043,27168438675,27868264704,27868866716,27868738288,27867965828 & response_type = zpl2 & caller.id = 23264143 & access_token = 400 Bad Request响应:   bad_request

0 个答案:

没有答案