YouTube API 3 从特定用户获取最后一个视频 [英] YouTube API 3 GET last videos from specific User

查看:26
本文介绍了YouTube API 3 从特定用户获取最后一个视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助以使用新的 API 版本检索特定用户的 YouTube 视频.

I need help to retrieve YouTube videos from specific user with the new API version.

我在 console.developers.google.com

OAuth 和浏览器的公共 API 访问.

之前我是用这段代码检索最新的6个视频:

Before I was use this code to retrieve the latest 6 video:

$feedURL = 'http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?max-results=6';
$sxml = simplexml_load_file($feedURL);
foreach ($sxml->entry as $entry) {
    $watch = (string)$media->group->player->attributes()->url;
}

如何使用 API 3 更新此代码?

How can I update this code with API 3?

推荐答案

我一直在 .net 中处理类似的事情,但它不像以前那么简单.

I've been working on a similar thing in .net and its not quite as simple as it used to be.

现在需要几个额外的步骤:

It now requires a couple of extra steps:

第 1 步:您需要通过以下方式获取用户的 channelId:

Step 1: you need to get the channelId for the user via:

https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername={0}&key={1} - 其中 {0} 是用户名,密钥是您的 API 密钥

https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername={0}&key={1} - where {0} is the USERNAME and key is you API key

第 2 步:从中您可以通过以下方式获取视频列表:

Step 2: from that you can get a list of videos via:

https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId={0}&key={1}

https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId={0}&key={1}

第 3 步:

https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,player&id={0}&key={1} - 其中 id 是从第 2 步返回的 videoId.

https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,player&id={0}&key={1} - where id is the videoId returned from step 2.

希望有所帮助.

这篇关于YouTube API 3 从特定用户获取最后一个视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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