I try to make an API Request to the Github API just for testing. I installed the latest Guzzle Version ( "guzzle/guzzle": "^3.9" ) on my Laravel 5.1 APP.
In my routes.php
i have the following Code:
Route::get('guzzle/{username}', function($username) {
$client = new Client([
'base_uri' => 'https://api.github.com/users/',
]);
$response = $client->get("/users/$username");
dd($response);
});
If i now visit the URL domain.dev/github/kayyyy i get the Error cURL error 6: Could not resolve host: users
.
Why am i getting this Error?
If i visit https://api.github.com/users/kayyyy i can see the json
output.
I am also using Homestead / Vagrant is this maybe a Problem that the host cant be resolved?
EDIT
If i try this without the base_uri it works.
Route::get('guzzle/{username}', function($username) {
$client = new GuzzleHttpClient();
$response = $client->get("https://api.github.com/users/$username");
dd($response);
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…