Reputation: 377
In my laravel application, I want to send http request with guzzle.
Here is my code:
$client = new GuzzleHttp\Client();
$res = $client->request('GET', 'https://api.github.com/user', [
'auth' => ['user', 'pass']
]);
echo $res->getStatusCode();
This results :
cURL error 6: Could not resolve host: api.github.com
How can I fix this?
Upvotes: 0
Views: 230
Reputation: 3420
I believe you need to define your auth constant,
$client = new \GuzzleHttp\Client();
define("auth", \GuzzleHttp\RequestOptions::AUTH );
$res = $client->request('GET', 'https://api.github.com/user', [
'auth' => ['user', 'pass']
]);
echo $res->getStatusCode();
Upvotes: 0