Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I want to try out the guzzle library and am following through their
quickstart
tutorial to make http requests to an api.
Yet it doesn't seem to work, because I get the following error:
cURL error 3: <url> malformed
Since I have never worked with cURL before, I don't even know how to respond to that error message. Here is my code with the request I am making:
$client = new Client();
$client->get('/', ['verify' => true]);
$response = $client->get('https://api.github.com/');
dd($response);
I am using the Laravel 5 framework and calling the index method in my HomeController. Also am using WAMP.
I would appreciate any help and suggestion, because I would like to try Guzzle out.
Here is a picture of the Error Message I get:
–
–
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
–
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'
–
$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 obviously not valid. When you instantiate the client, use the base_uri
option, or specify a full URL in the call to get()
.
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.