Haniye Shadman
Haniye Shadman

Reputation: 377

cURL error 6 in sending request with guzzle

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

Answers (1)

bhucho
bhucho

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

Related Questions