2012-03-15 24 views
2

我想知道是否有可能嵌入youtube视频的评论和喜欢按钮与视频? 如果有这样的事情,我该怎么做,或者我可以从哪里获得更多信息?由于嵌入youtube的评论,并像

+0

你在用什么语言? – 2012-03-15 15:12:29

回答

0

您可以通过处理此URL

http://gdata.youtube.com/feeds/api/videos/{$videoID}/comments

一样的功能YouTube的访问YouTube的评论需要将登录到他/她的谷歌帐户的用户

2

在这里你可以看到一个例如,如何获取和显示视频评论

Getting Youtube Video Information using javascript/jquery

,并在主题浏览器项目,你可以看到如何添加 '喜欢' 或视频添加到您的收藏夹:

https://code.google.com/p/yt-topic-explorer/source/browse/app/views/main.html

<button ng-click="addToList($event.target, 'likes', videoResult.id)">{{'LIKE'|i18n}}</button> 
<button ng-click="addToList($event.target, 'favorites', videoResult.id)">{{'FAVORITE'|i18n}}</button> 

和:

https://code.google.com/p/yt-topic-explorer/source/browse/app/scripts/controllers/main.js

$scope.addToList = function(target, listName, videoId) { 
    var listId = $rootScope.relatedPlaylists[listName]; 

    target.textContent = topicExplorerApp.filter.i18n('ADDING'); 
    target.disabled = true; 

    youtube({ 
     method: 'POST', 
     service: 'playlistItems', 
     params: { 
     part: 'snippet' 
     }, 
     body: { 
     snippet: { 
      playlistId: listId, 
      resourceId: { 
      kind: constants.VIDEO_KIND, 
      videoId: videoId 
      } 
     } 
     }, 
     callback: function(results) { 
     if ('error' in results) { 
      target.textContent = 'Error'; 
     } else { 
      target.textContent = topicExplorerApp.filter.i18n('ADDED'); 
     } 
     } 
    }); 
    }; 
1

编辑: 2016年2月,YT已经停止了解决方案以下工作:-(我会保留它这里仅作参考

的意见:

作为YT已经过时的意见网址GDATA,你也可以凑“时间从这里开始;其解决方法虽然:D

https://www.youtube.com/all_comments?v=cOIKAnF3mjs 

...无需认证! :)如果你想工作的客户端仅(在这个例子中通过跨域),经过JS

<textarea style="width:100%;height:100%" id=cu></textarea> 
<script> 
var r=''; 
function c(d) 
      { 
      for(i=0;i<=d.query.count-1;i++) 
       r=r+d.results[i]; 
      document.getElementById('cu').innerHTML=r; 
      } 
</script> 
<script src="http://query.yahooapis.com/v1/public/yql?q=%20SELECT%20*%20FROM%20html%20WHERE%20url%3D%22https://www.youtube.com/all_comments?v=cOIKAnF3mjs%22&callback=c"></script> 
1

YouTube不会有,您可以使用嵌入任何评论嵌入代码。所以基本上有两个选项来嵌入评论 -

1.使用YouTube API来嵌入和发表评论。这将需要一个良好的编码知识。

获得评论使用此终结

GET https://www.googleapis.com/youtube/v3/commentThreads 

添加注释使用此终结

POST https://www.googleapis.com/youtube/v3/playlistItems 

2.或者你可以使用现成的插件,允许这项功能。这里是一个小的demo of the Youmax plugin,它将列出评论以及允许您添加评论。