javascript - 从一个请求中通过 id 获取多个 youtube 视频的信息?

标签 javascript youtube youtube-api

我可以使用 youtube api(2.0 版)从一个请求中获取多个 youtube 视频的信息吗?

Retrieving information about a single video

从上面的链接,我可以知道如何通过id获取single视频的信息。例如:

https://gdata.youtube.com/feeds/api/videos/ylLzyHk54Z0?v=2&fields=title,author,yt:statistics,yt:rating&alt=json

但是我如何从一个请求中通过他们的 id 获取两个视频信息?我已经阅读了开发人员指南,似乎没有关于我的问题的内容。 youtube api 3.0 版可以做到这一点吗?

希望大家帮帮忙! 非常感谢!

最佳答案

你应该使用 YouTube API v2.0 – Using Batch Processing .

您可以发布这样的 XML:

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:yt="http://gdata.youtube.com/schemas/2007">
    <batch:operation type="query" />
    <entry>
        <id>http://gdata.youtube.com/feeds/api/videos/weRefE-qw9</id>
    </entry>
    <entry>
        <id>http://gdata.youtube.com/feeds/api/videos/kkT-t894YSa</id>
    </entry>
    ...
</feed>

到这个网址:

http://gdata.youtube.com/feeds/api/videos/batch

这是引用自文档:

The YouTube Data API supports batch processing, enabling you to execute up to 50 operations with a single API request rather than submit a separate request for each individual operation. A batch processing request can combine multiple query (GET), insert (POST), update (PUT) and delete (DELETE) operations. Each operation is contained within an <entry> tag in the request. This section explains how to format batch processing requests and handle the API responses to those requests.

关于javascript - 从一个请求中通过 id 获取多个 youtube 视频的信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16386768/

相关文章:

java - YouTube 上传错误 - 上传失败 : Can't process file

javascript - 如何在JS中获取A href

javascript - 我们如何更改 v2 div 中存在的 p 标签的值?

google-chrome-extension - Chrome 扩展页面内的 YouTube 嵌入视频在 Chrome 56 中显示为后矩形

android - 您的应用包含公开的 Google Cloud Platform (GCP) API key

youtube - 使用YouTube RSS API时出现异常流量(403)错误

javascript - AngularJS 在 Html Table 上观看

javascript - 在CSS中动态更改内容

javascript - 使用 WKWebview 在 super View 更改后调整 Youtube iframe 的大小

android - 奇怪的问题填补了自定义列表