2011-01-14 36 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>