2011-01-14 44 views

回答

1

它返回一个XML文件,所以使用simpleXML来解析它。

+0

我不想,我可以从那里得到标题,我正在要求一种方式,让该页面只输出标题直接 – ted 2011-01-14 12:18:50

+0

哦,我明白了。对不起,我不认为有人浏览过API文档。 – 2011-01-14 12:25:37

6

不知道这是否会有所帮助,因为我以前从来没有使用过youtube API。我昨天碰到了这个消息。根据http://dl.google.com/googleio/2010/googleapis-how-google-builds-apis.pdf,您可以使用fields=entry(title)(尽管我认为它用于搜索视频)执行“部分获取”(仅针对“部分响应”搜索该pdf)。通过查询实际的视频ID而不是字符串,它将只返回那一个视频。

实施例:

http://gdata.youtube.com/feeds/api/videos?v=2&q=[video_id]&max-results=1&fields=entry(title)&prettyprint=true 
2

http://gdata.youtube.com/feeds/api/videos/[id]?fields=title

实验但工作。与 “标题:”

4
<? 
$id = 'VIDEOID'; 
$xmlData = simplexml_load_string(file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$id}?fields=title")); 

$title = (string)$xmlData->title; 

echo $title; 
0

前缀搜索词,例如:

http://gdata.youtube.com/feeds/base/videos?q=title:<search term>