2017-12-06 3 views

답변

1

이것은 guzzle를 당겨서 할 수 있습니다. 시도 : https://github.com/guzzle/guzzle

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

희망이 당신을 도와줍니다!

+1

내 대답을 받아 주셔서 감사합니다! 나는 내 의견으로 앤서스 대답에서 당신에게 첫 번째 대답을 줄 것이다! 그것을보고 주셔서 감사하고 해결책으로 받아들입니다! –

1

컨트롤러에서 해당 URL에 대한 요청을 수행해야합니다. 이것은 대머리를 당겨서 할 수 있습니다. 이 저장소의 readme를보십시오 : https://github.com/guzzle/guzzle

+0

이미 시도했지만 공백 응답을 제공합니다. $ client = new Client(); $ api_response = $ client-> get ('mtaapi.herokuapp.com/stations'); // $ response = json_decode ($ api_response); dd ($ api_response); –

+0

@ParthSureliya 다음과 같이하십시오 :'$ client = new Client(); $ body = $ client-> get ('mtaapi.herokuapp.com/stations') -> getBody(); $ obj = json_decode ($ body);'희망이 도움이됩니다! –

+1

$ api_response-> getBody();를 덤프 해보십시오. 거기 뭐라구? – Anders

관련 문제