fetch data from omdbapi

Asked

Viewed 26 times

0

I have this code (meusite.com/imdb.php)

<?php
$movie_id = 'tt0387564';
$data = json_decode(file_get_contents('http://www.omdbapi.com/?i=' . $movie_id . '&plot=short&apikey=') , true);
$data2 = json_decode(file_get_contents('https://api.themoviedb.org/3/movie/' . $movie_id . '?language=pt-PT&api_key=') , true);
if (empty($movie_id))
{
    echo '';
    die();
}

echo '
<div class="container">
<div class="poster"><img src="' . $data['Poster'] . '"/></div>
<div class="Title">' . $data['Title'] . '</div>
<div class="Year">' . $data['Year'] . '</div>
<div class="Genre">' . $data['Genre'] . '</div>
<div class="imdbRating">' . $data['imdbRating'] . '</div>
<div class="Director">' . $data['Director'] . '</div>
<div class="Actors">' . $data['Actors'] . '</div>
<div class="overview">' . $data2['overview'] . '</div>
</div>
';
?>

How do I get the &movie_id without always having to change the . php file? Example: meusite.com/imdb.php?movie_id=tt0387564

  • How to change the file?

  • my knowledge of php is very few, what I wanted was to fetch the information of the movies by movie_id without having to change the php file, for example: meusite.com/imdb.php? movieid=tt*****

  • Ah, okay, I get it. What feedback are you getting?

  • I already did, just add these lines <? php if (!isset($_GET['movieid'])) { die('require param movieid'); } $movie_id = $_GET['movieid']; // debug // var_dump($movie_id); die;

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.