I have a laravel application that I'm creating. The web routes calls the API for information. When I test my API it returns data, but when the front end dev calls the API it slows the system and returns a failure. This is a simple GET that was working before but is not working now.
This is the the API call from the web:
$url = 'http://localHost:8000/api/v1.0/theater_movies';
$opts = array('http'=>array('http' => array(
'protocol_version' => 1.1,
'user_agent' => 'PHPExample',
'method' => 'GET',
'header' => "Content-type: application/json\r\n")
));
//Basically adding headers to the request
$context = stream_context_create($opts);
$getMovies = json_decode(file_get_contents($url,false,$context), true);
I'm getting the file_get_contents error: file_get_contents(http://localhost:8000/api/v1.0/theater_movies): failed to open stream: HTTP request failed!
And this is the correct output from Postman 
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire