Reputation: 256
I want to use MTA API (Metropolitan Transportation Authority ) service. But when I send a request it will return one file. How can I get data from MTA API?
http://datamine.mta.info/mta_esi.php?key=MYAPIKEY&feed_id=26
Upvotes: 1
Views: 281
Reputation: 11646
first install guzzlehttp package for laravel
using composer
,
composer require guzzlehttp/guzzle
use it's namespace in your controller:
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
Then you can simply do,
$client = new Client();
$api_response = $client->get('http://datamine.mta.info/mta_esi.php?key=MYAPIKEY&feed_id=26');
$response = json_decode($api_response);
// do your stuff with the response
Upvotes: 1