Guzzle returns cURL error 3: <url> malformed

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 03:06:41

If you want to disable verification (don't do this!):

$response = $client->get('https://api.github.com/', ['verify' => false]);

Rather than disabling verification entirely, this can likely be fixed by providing proper CA bundle file. See verify in Guzzle documentation.

$client->setDefaultOption(
    'verify', 
    'C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt'
);

You should not have this call:

$client->get('/', ['verify' => true]);

That is what is throwing the error. The third line is okay.

The error is means what it says. The url is malformed. In my case on initialization of the Client, I used base_url instead of base_uri. So if you run into this error make sure your url is properly specified.

In case you came here because you googled "Guzzle returns cURL error 3: malformed" check the client parameter. In some version it's base_uri and other base_url

    $client = new Client([
        'base_uri' => 'http://localhost:8000',  // <-- base_uri instead of base_url
    ]);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!