Fetching YouTube video title from known video id

*爱你&永不变心* 提交于 2019-12-03 16:20:36

Yes, it is possible using Javascript and JSON.

https://developers.google.com/youtube/2.0/developers_guide_protocol_video_entries

See: https://developers.google.com/youtube/2.0/developers_guide_json

So you do it like this:

<script 
type="text/javascript" 
src="https://gdata.youtube.com/feeds/api/videos/videoid?v=2&alt=json-in-script&format=5&callback=getTitle">
</script>

And then:

function getTitle(data) {
 var feed = data.feed;
 var entries = feed.entry || [];
  for (var i = 0; i < entries.length; i++) {
   var entry = entries[i];
   var title = entry.title.$t;
  }
 } 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!