Parth Sureliya
Parth Sureliya

Reputation: 256

How to get response from another site in laravel controller

I want to create API in laravel which gives data return. I want to get data from this link into my laravel controller.

Upvotes: 1

Views: 1811

Answers (2)

Hiren Gohel
Hiren Gohel

Reputation: 5041

This can be done by pulling in guzzle. Try: https://github.com/guzzle/guzzle

$client = new Client(); 
$body = $client->get('mtaapi.herokuapp.com/stations')->getBody(); 
$obj = json_decode($body);

Hope this helps you!!

Upvotes: 1

ajthinking
ajthinking

Reputation: 4598

You need to do a request to that url from your controller. This can be done by pulling in guzzle. Please see the readme of this repository: https://github.com/guzzle/guzzle

Upvotes: 1

Related Questions