Doing HTTP requests FROM Laravel to an external API

Tags: , , ,

What I want is get an object from an API with a HTTP (eg, jQuery’s AJAX) request to an external api. How do I start? I did research on Mr Google but I can’t find anything helping.

Im starting to wonder is this is even possible? In this post Laravel 4 make post request from controller to external url with data it looks like it can be done. But there’s no example nor any source where to find some documentation.

Please help me out?


Based upon an answer of a similar question here:

Take a look at Guzzle

$client = new GuzzleHttpClient();
$res = $client->get('', ['auth' =>  ['user', 'pass']]);
echo $res->getStatusCode(); // 200
echo $res->getBody(); // { "type": "User", ....

Source: stackoverflow