intitle:信息检索_PHPTVDB:使用PHP检索电视节目信息

intitle:信息检索

The Office (UK)

I'm a bigtime TV/movie buff. If it's ever seen the light of day on HBO or BBC America, I've seen it (and quite possibly filmed my own made-for-TV-short-film). Unfortunately IMDB doesn't provide an official API for movies and TV shows but thankfully TVDB does.

我是电视/电影迷。 如果曾经在HBO或BBC America上看到过这种情况,那我就已经看过(而且很可能拍摄了我自己为电视制作的短片)。 不幸的是,IMDB没有提供用于电影和电视节目的官方API,但值得庆幸的是TVDB可以提供。

Retrieving information from TVDB is a breeze using a small library called PHPTVDB written by Ryan Doherty. With a little PHP knowledge and TVDB API key, you can easily grab data about any TV show.

使用Ryan Doherty编写的名为PHPTVDB的小型库,从TVDB检索信息非常容易。 只需一点PHP知识和TVDB API密钥,您就可以轻松获取有关任何电视节目的数据。

PHP (The 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>";


The above is just a sample usage of this great PHP library. You can find documentation here. Remember to try to be specific in your initial show search. I recommend going to IMDB or TVDB to get the show's "official" name to confirm you are being as specific as possible.

上面只是这个出色PHP库的示例用法。 您可以在此处找到文档 。 切记在最初的演出搜索中尽量做到具体。 我建议去IMDB或TVDB获得节目的“正式”名称,以确认您的身份尽可能具体。

翻译自: https://davidwalsh.name/phptvdb

intitle:信息检索

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值