What is the easiest way to get the title from the youtybe video , for example this video title :
http://www.youtube.com/watch?v=Wp7B81Kx66o
Thanks !
What is the easiest way to get the title from the youtybe video , for example this video title :
http://www.youtube.com/watch?v=Wp7B81Kx66o
Thanks !
Try this:
<script type="text/javascript">
function showMyVideos(data) {
var feed = data.feed;
var entries = feed.entry || [];
var html = ['<ul>'];
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
var title = entry.title.$t;
html.push('<li>', title, '</li>');
}
html.push('</ul>');
document.getElementById('videos').innerHTML = html.join('');
}
</script>
and this in your body part:
<body>
<div id="videos" />
<script
type="text/javascript"
src="http://gdata.youtube.com/feeds/users/GoogleDevelopers/uploads?alt=json-in-script&format=5&callback=showMyVideos">
</script>
</body>
Use jQuery's JSON call to the YouTube API to get the results back and then use jQuery to put the results where you want them. You can use firebug's NET tab to make sure you requests/respoonses are coming back correctly and then use console.log() to make sure you parsed the response correctly.