YouTube API V3 - 来自用户名的最新视频 [英] YouTube API V3 - Latest video from username

查看:28
本文介绍了YouTube API V3 - 来自用户名的最新视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 JavaScript 显示发布到网站上 youtube 频道的最新视频的缩略图 - 我已经看到如何使用 API 的 v2 执行此操作,但似乎无法找到使用 v3 的示例.示例请求似乎是使用一组视频完成的:

I am trying to display the thumbnail from the latest video posted to a youtube channel on a website by using JavaScript - I have seen how to do this with v2 of the API but cannot seem to find an example of this using v3. The example requests seem to be done using a set video:

https://developers.google.com/youtube/v3/getting-started

而不是频道/用户名.

我看过交互式演示,但这似乎只有 v2?

I have seen the interactive demo but this seems to be v2 only?

http://gdata.youtube.com/demo/index.html

任何指向正确方向的指针将不胜感激.在 v2 中这样做是不是一个愚蠢的想法?

Any pointers in the right direction would be appreciated. Is it a silly idea to do this in v2 instead?

推荐答案

您将分两步完成此操作.首先,您需要使用 v3 获取该 videoId,然后您可以像示例中一样显示它.

You will do this in two steps. First you will need to get that videoId using v3, then you can show it as in the example.

所以第一步将是 channels->list 调用,作为响应,您将获得 上传播放列表 ID.然后您将此 ID 插入 playlistItems->list 调用以设置 playlistId 过滤器.如果您将 maxResults 设置为 1.那只会返回 最后一个视频的 ID.

So the first step will be a channels->list call, in response you will get uploads playlist ID. Then you will plug this id into playlistItems->list call to set playlistId filter. If you set maxResults to 1. That will only return the last video's id.

这篇关于YouTube API V3 - 来自用户名的最新视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆