我想顯示的已上傳到頻道的視頻列表。
我在哪裏至今
我明白,這是對用戶的JSON格式「上傳」正確的網址:
http://gdata.youtube.com/feeds/api/users/%USERNAME%/uploads?alt=json&v=2
,其中的用戶名是通道的名稱,而比對應於用戶頻道的字母/數字字符串(例如,MyChannel而不是hIANSUBhkj_baisu128)。
但是,當在我的用戶名(BenPearlMagic
)上測試此項時,我收到一個非常長的JSON列表,其中包含大量似乎不相關的數據。
我的代碼是這樣的:
$.getJSON('http://gdata.youtube.com/feeds/api/users/benpearlmagic/uploads?alt=json', function(data) {
console.log(data);
for(var i=0; i<data.data.items.length; i++) {
console.log(data.data.items[i].title); // title
console.log(data.data.items[i].description); // description
}
});
...但我無法得到它的工作。
完美 - 謝謝。 – Ben
太好了! ...雖然此解決方案將於2015年4月20日棄用! https://developers.google.com/youtube/terms#deprecation –