Created
May 29, 2012 16:09
-
-
Save PolCPP/2829250 to your computer and use it in GitHub Desktop.
Get youtube views with jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_views(video_id) { | |
var URL = "https://gdata.youtube.com/feeds/api/videos/"+video_id+"?v=2&alt=json"; | |
$.ajax({ | |
type: "GET", | |
url: URL, | |
cache: false, | |
dataType:'jsonp', | |
success: function(data){ | |
// Add your logic here. As an example it just logs it on the console | |
console.log(data.entry.yt$statistics.viewCount); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment