jQueryYouTube检索描述

jQueryYouTube检索描述,jquery,json,youtube,Jquery,Json,Youtube,我如何添加到这段代码中,以便它在iframe中提取描述、标题和视频 JavaScript: $(function() { var htmlString = "<ul>"; $.getJSON('http://gdata.youtube.com/feeds/users/(MY USER)/uploads?alt=json-in-script&callback=?&max-results=3', function(data) { $.

我如何添加到这段代码中,以便它在iframe中提取描述、标题和视频

JavaScript:

$(function() {
    var htmlString = "<ul>";
    $.getJSON('http://gdata.youtube.com/feeds/users/(MY USER)/uploads?alt=json-in-script&callback=?&max-results=3', function(data) {
           $.each(data.feed.entry, function(i, item) {                                     
                   var title = item['title']['$t'];
                    var video = item['id']['$t'];
                    video_link = video.replace('http://gdata.youtube.com/feeds/videos/','http://www.youtube.com/watch?v=');
                    video_object = video.replace('http://gdata.youtube.com/feeds/videos/','http://www.youtube.com/v/');
                    htmlString +='<li><p id="video_title">' + title + '</p><object width="600" height="450"><param name="movie" value="' + video_object + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + video_object + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="450"><noembed>Browser does not support video</noembed></embed></object></li>';
            });
            $('#videos').html(htmlString + "</ul>");
    });
$(函数(){
var htmlString=“
    ”; $.getJSON('http://gdata.youtube.com/feeds/users/(我的用户)/在脚本和回调中上载?alt=json=?&max results=3',函数(数据){ $.each(data.feed.entry,函数(i,项){ var title=项目['title']['$t']; var video=项目['id']['$t']; 视频链接=视频。替换('http://gdata.youtube.com/feeds/videos/','http://www.youtube.com/watch?v='); video\u object=video.replace('http://gdata.youtube.com/feeds/videos/','http://www.youtube.com/v/'); htmlString+='
  • '+title+'

    浏览器不支持视频; }); $('#videos').html(htmlString+“
”); });
HTML:

<div id="videos"></div>

如果您在getJson中读取url,您会注意到url需要一个用户名和一个回调方法。您缺少这两个

(我的用户)/uploads?脚本中的alt=json&回调=?&max results=3

您可以在指南中阅读更多关于如何使用youtubes api的信息 试试:

var desc = item.media$group.media$description.$t;

嗯,我发布的代码工作得很好,我只是从url中删除了用户名,它正在拉视频并将其发布到iframe和标题中。我所需要做的就是拉描述。。。