如何嵌入我最近在 YouTube 上分享的视频?
尝试阅读有关在我的网站上嵌入视频的官方指南网站,但我没有找到教如何嵌入我的 YouTube 区域上加载的最后一个视频的部分。
可以吗(使用JS API)?
编辑 回调以检查视频并执行一些操作,
<head>
<script type="text/javascript" src="http://gdata.youtube.com/feeds/users/MyNickname/uploads?alt=json-in-script&format=5&callback=showMyVideos"></script>
<script type="text/javascript">
function showMyVideos(data) {
alert("Hello");
}
</script>
</head>
这应该显示我的警报,但没有任何反应。为什么=
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下 URL 获取特定用户上传的 JSON 格式的视频列表。
注意:alt=json 并将 GoogleDevelopers 替换为您的用户。
您可以使用 jQuery.ajax() 从 URL 获取数据,然后获取第一个饲料(最新的)
You could use the following URL to get the list of uploaded video by particular user in JSON format.
Note : alt=json and to replace GoogleDevelopers with your user.
You could use jQuery.ajax() to get the data from the URL then just get the first feed (the latest one)
您需要使用YT Data API 的这一部分 。返回的视频的顺序是最近上传的,因此您可以从返回的列表中获取第一个。
例如:
https://gdata.youtube.com/feeds/api/users/SocialGo/uploads?alt=json&fields=entry/id,entry/published
You'll want to use this section of the YT Data API. The order of returned videos is most recently uploaded first, so you can just grab the first off the returned list.
For example:
https://gdata.youtube.com/feeds/api/users/SocialGo/uploads?alt=json&fields=entry/id,entry/published