我是一个超级电视/电影迷。如果它曾经在 HBO 或 BBC America 上看到过,我已经看过了(而且很可能拍摄了我自己制作的电视短片)。不幸的是,IMDB 没有为电影和电视节目提供官方 API,但幸运的是 TVDB 提供了。
使用由 Ryan Doherty 编写的名为 PHPTVDB 的小型库,可以轻而易举地从 TVDB 中检索信息。只需一点 PHP 知识和 TVDB API 密钥,您就可以轻松获取有关任何电视节目的数据。
PHP
/* include the library */ require 'phptvdb-1.0.2/TVDB.php'; /* get the office! */ $shows = TV_Shows::search('The Office UK'); /* get the first show */ $show = $shows[0]; /* a few shortcuts / formatted vars */ $firstAired = date('l, F j, Y',$show->firstAired); $imdb_url = "http://imdb.com/title/$show->imdbId"; /* spit out the show information */ echo "<h2>$show->seriesName</h2> <div class=\"meta\"> <strong>Rating:</strong> $show->rating • <strong>Debuted:</strong> $firstAired on $show->network • <a href=\"$imdb_url\">$show->seriesName on IMDB</a> </div> <p>$show->overview</p>"; /* my favorite episode info */ $episode = $show->getEpisode(1,4); echo "<div class=\"righty\"> <h3>Favorite Episode: $episode->name</h3> <p>$episode->overview</p> </div>"; /* spit out the actors */ echo '<h3>The Cast</h3><ul>'; foreach($show->actors as $actor) { echo "<li>$actor</li>"; } echo '</ul><br />'; /* learn more link */ echo "<p><a href=\"http:/* imdb.com/title/\">Learn more about \"$imdb_url\" on IMDB</a></p>";
以上只是这个很棒的 PHP 库的示例用法。您可以在此处找到文档。请记住在最初的节目搜索中尽量做到具体。我建议去 IMDB 或 TVDB 获取节目的“官方”名称,以确认您尽可能具体。