JSON 无法访问数据并收到错误 404 (TMDB)?

JSON data cannot be accessed getting error 404 (TMDB)?

我要TMDB所需电影的海报。我无法从 TMDB API 获取 JSON 数据。我已发送请求,但收到错误 404 'The resource you requested could not be found'。 Link 访问 TMDB 电影 API : https://developers.themoviedb.org/3/movies/get-movie-images 这是我的代码:

<script type="text/javascript">
    var film = "speed";
    var api_key = 'my-api-key';
    var requestURL = "https://api.themoviedb.org/3/movie/images?api_key=" + api_key +"&language=en-US&callback=?";

    var request = new XMLHttpRequest();

    request.open('GET', requestURL);

    request.responseType = 'json';

    request.send();

    request.onload = function(){
        var myjsondata = request.response; //request.response contains all our JSON data 

        console.log(myjsondata);
    } 
</script>

我的控制台中的 JSON 数据应该如下所示:

但是我在 console:error 404 找不到这个资源。

您需要在请求 URL 的路径部分包含一个 movie_id 值,对吗?像这样:

var requestURL = "https://api.themoviedb.org/3/movie/"
  + movie_id + "/images?api_key=" + api_key +"&language=en-US&callback=?";

至少 in the documentation cited in the question 显示的是:

GET /movie/{movie_id}/images

Path Parameters

movie_id : integer

Example:

https://api.themoviedb.org/3/movie/{movie_id}/images?api_key=<<api_key>>

例如,要获取 ID 为 9340 的电影图像的 JSON 格式的数据:

https://api.themoviedb.org/3/movie/9340/images?api_key=<<api_key>>

您可以通过 curl 或其他任何方式进行测试来确认是否有效:

$ curl "https://api.themoviedb.org/3/movie/9340/images?api_key=<<api_key>>"

{
    "backdrops": [
        {
            "aspect_ratio": 1.777251184834123,
            "file_path": "/qKeyO9gXaaK0g87tvvqOPK1siwc.jpg",
            "height": 1688,
            "iso_639_1": null,
            "vote_average": 5.454545454545455,
            "vote_count": 3,
            "width": 3000
        },
        …