i am new to api and i am having issues with the api requests
i am creating a streaming website and i searched for every movie in the TMDB i got the movie id and i added it into the database
so when the user clicks on one of the movie a script will get the movie id that matches the movie name in mysql (i dont know if this is the right way or not)
i only have movies in my website and only request these info title name - description - poster_path - category - runtime - year - imbdrating - actors with there posters.
everything works fine but sometimes my page give me Undefined variables for my requests and when i check my request log i fond that i am request random information not related to my requests like,
200 GET /3/tv/2 - 200 GET /3/search/multi - 200
GET /3/trending/all/day 7/28/2023 12:11 PM
200
GET /3/trending/all/day 7/28/2023 12:10 PM 200
GET /3/trending/all/day 7/28/2023 12:11 PM
200
GET /3/trending/all/day 7/28/2023 12:10 PM
simply a random requests so i dont know what to do hope i get help
code text here
// Fetch movie details from TMDB using the provided function
list($movieTitle, $movieDescription, $posterPath, $releaseYear, $runtime, $genres, $imdbRating) = getMovieDetails($MovieId, $apiKey);
function getMovieDetails($MovieId, $apiKey) {
$baseUrl = "https://api.themoviedb.org/3/movie/{$MovieId}";
$query = http_build_query([
'api_key' => $apiKey,
'append_to_response' => 'credits',
]);
try {
$httpClient = new \GuzzleHttp\Client();
$response = $httpClient->get("$baseUrl?$query");
$data = json_decode($response->getBody(), true);
$movieTitle = $data['title'];
$movieDescription = $data['overview'];
$posterPath = $data['poster_path'];
$releaseYear = date('Y', strtotime($data['release_date']));
$runtime = $data['runtime'];
$genres = array_column($data['genres'], 'name');
$imdbRating = number_format($data['vote_average'], 1);
لم تجد الفلم أو المسلسل ؟ سجل دخولك و انشئها
هل تريد تقييم او اضافة هذا العنصر للقائمة؟
لست عضو؟