Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guzzle returns cURL error 3: <url> malformed

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:

Laravel 5 Error Message

like image 942
LoveAndHappiness Avatar asked Apr 18 '15 21:04

LoveAndHappiness


People also ask

How do I fix curl error 3?

php file in it. Only then the Laravel app can use the payment gateway without error. After that, we cleared both the config cache and app cache in Laravel. Hence it fixed the error.

Why is this URL malformed?

This violation indicates that a request that was not created by a browser, and does not comply with HTTP standards, has been sent to the server. This may be the result of of an HTTP request being manually crafted or of a client tunneling other protocols over HTTP.


1 Answers

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     ]); 
like image 125
Kaizoku Gambare Avatar answered Sep 24 '22 21:09

Kaizoku Gambare