我發現這個網站,它提供IMDB API: http://www.omdbapi.comIMDB Api,只檢索標題和情節。
,併爲獲得例如霍比特人的這是很容易,因爲這: http://www.omdbapi.com/?i=tt0903624
然後我得到的所有信息:
{"Title":"The Hobbit: An Unexpected Journey","Year":"2012","Rated":"11","Released":"14 Dec 2012","Runtime":"2 h 46 min","Genre":"Adventure, Fantasy","Director":"Peter Jackson","Writer":"Fran Walsh, Philippa Boyens","Actors":"Martin Freeman, Ian McKellen, Richard Armitage, Andy Serkis","Plot":"A curious Hobbit, Bilbo Baggins, journeys to the Lonely Mountain with a vigorous group of Dwarves to reclaim a treasure stolen from them by the dragon Smaug.","Poster":"http://ia.media-imdb.com/images/M/[email protected]@._V1_SX300.jpg","imdbRating":"9.2","imdbVotes":"5,666","imdbID":"tt0903624","Response":"True"}
事情是,我只想爲例如標題,年份和情節信息,我想知道我只能檢索這個。
我想使用PHP。
當我嘗試頂級解決方案時得到了這個:「致命錯誤:不能使用類型爲stdClass的對象作爲數組在」 – user1133188
這是因爲json_decode的默認值是作爲一個對象。我已經添加了一個編輯(只要它得到審查),通過將第二個參數設置爲數組進行解碼來修復該編輯。作爲替代方案,您可以使用第一個示例中的對象表示法訪問默認的json_decode數據,如下所示:''Title'=> $ data-> Title,'Plot'=> $ data-> Plot' – taswyn