Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Fetching YouTube video title from known video id

I want to fetch a YouTube video title when the video id is known, using JavaScript only. Is it possible?

like image 522
Rukmi Patel Avatar asked May 15 '12 08:05

Rukmi Patel

1 Answers

Yes, it is possible using Javascript and JSON.


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

So you do it like this:


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;
like image 64
Daniel Ruf Avatar answered Nov 01 '22 05:11

Daniel Ruf