I want to fetch external api in my project in laravel. what is the best way to fetch api in laravel??
CodePudding user response:
Everything is described in the documentation of Laravel, you can/should use Laravel Http Facade
https://laravel.com/docs/9.x/http-client
CodePudding user response:
You can use the
Curl for the using external apis in laravel project
You can install Guzzle through composer composer require guzzlehttp/guzzle:~6.0
composer.json
{ "require": { "guzzlehttp/guzzle": "~6.0" } }
//code is here
$client = new GuzzleHttp\Client(); $res = $client->get('https://api.github.com/user', ['auth' => ['user', 'pass']]); echo $res->getStatusCode(); // 200 echo $res->getBody();