You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Xero API时持续出现cURL error 18问题求助

连接Xero API时持续出现cURL错误18

我正在开发一款Web应用,通过Laravel对接Xero的API获取联系人与发票数据。起初数据获取正常,之后开始不定期出现cURL错误18,现在已经持续报错。

查看Xero开发者控制台,请求返回状态码为200,因此判断问题出在本地。

发起请求的代码

protected function guzzle ($type, $request, $data = [], $raw = false)
{
    try {
        
        $client = new Client;

        $headers = [
            'Accept'         => 'application/json',
            'Authorization'  => 'Bearer '.$this->getAccessToken(),
            'Xero-tenant-id' => $this->getTenantId(),
            'Accept-Encoding' => 'gzip, deflate',
        ];

        $response = $client->$type(self::$baseUrl.$request, [
            'headers' => $headers,
            'body'    => $raw ? $data : json_encode($data),
        ]);
        

        return [
            'body'    => json_decode($response->getBody()->getContents(), true),
            'headers' => $response->getHeaders()
        ];
        
        
    } catch (ClientException $e) {

        throw new Exception($e->getResponse()->getBody()->getContents());

    } catch (Exception $e) {
          
        throw new Exception($e->getMessage());
    }
}

错误详情

cURL错误18:传输已关闭,但仍有未读取的数据残留,该错误在执行$response时触发,被catch (Exception $e)代码块捕获。

我已经尝试了网上几乎所有解决方案,但都没有效果,希望能得到帮助。


内容的提问来源于stack exchange,提问作者fufubrocat

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 15:32:46