的我試圖做到這一點:基本使用的API(爛番茄API)
使用爛番茄API通過查詢電影ID列表返回影片的名單。
現在,我以前沒有使用過API,所以我找到了我的概念。我選擇用javascript去與數據進行交互,使用這些例子我測試的基礎:
var apikey = "myapikey";
var baseUrl = "http://api.rottentomatoes.com/api/public/v1.0";
// construct the uri with our apikey
var moviesSearchUrl = baseUrl + '/movies.json?apikey=' + apikey;
var query = "Gone with the Wind";
$(document).ready(function() {
// send off the query
$.ajax({
url: moviesSearchUrl + '&q=' + encodeURI(query),
dataType: "jsonp",
success: searchCallback
});
});
// callback for when we get back the results
function searchCallback(data) {
$(document.body).append('Found ' + data.total + ' results for ' + query);
var movies = data.movies;
$.each(movies, function(index, movie) {
$(document.body).append('<h1>' + movie.title + '</h1>');
$(document.body).append('<img src="' + movie.posters.thumbnail + '" />');
});
}
即使用搜索作爲返回電影列表的方式,但我已經有預先定義的電影列表,我想要返回。
API使用這個網址使用的ID
api.rottentomatoes.com/api/public/v1.0/movies/[MOVIE_ID_HERE].json?apikey=ny97sdcpqetasj8a4v2na8va
我的問題是返回一個特定的電影,如何創建將使用這些URL參數返回,首先,電影具有特定ID的功能,然後進一步從給定的一組ID中返回電影列表。
我想我的問題是關於必要的JS與該URL一起使用,而不是太專用於腐爛的番茄API本身。
感謝@mfreitas的評論,他們對RT API有一些很好的見解,我已經重新搜索過,它看起來像The Movie Data基地API是一個更好的選擇:http://docs.themoviedb.apiary.io/ – Dave