Youtube Live Streaming API 使用限制

Posted

技术标签:

【中文标题】Youtube Live Streaming API 使用限制【英文标题】:Youtube Live Streaming API usage limitations 【发布时间】:2017-08-21 16:01:37 【问题描述】:

Youtube Live Streaming API 有非常详尽的文档,我浏览了它以及使用示例。最近我开始收到 403 错误。

错误的完整签名是:

Error calling POST 

https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet%2Cstatus%2CcontentDetails: 

(403) Request is not authorized

而且我无法找出背后的原因。在一天开始时,使用谷歌帐户凭据和OAuth 密钥一切正常。然后在几次请求成功后,它与403 一起下降。使用了相同的凭据和密钥。

我坚信游戏存在限制,但这些限制是什么或如何绕过它们,我无法在文档或其他地方找到。

代码是这样的(直到断点):

$liveStreamingApi = new LiveStreamingApi();
$youtube = $liveStreamingApi->setLiveBroadcasts($returnUrl, null, LiveStreamingApi::CREATE);

$broadcastSnippet = new \Google_Service_YouTube_LiveBroadcastSnippet();
$broadcastSnippet->setTitle($model->name);

$broadcastSnippet->setScheduledStartTime(STARTTIME);
$broadcastSnippet->setIsDefaultBroadcast('1');

$status = new \Google_Service_YouTube_LiveBroadcastStatus();
$status->setPrivacyStatus($privacy);

$broadcastInsert = new \Google_Service_YouTube_LiveBroadcast();
$broadcastInsert->setSnippet($broadcastSnippet);
$broadcastInsert->setStatus($status);
$broadcastInsert->setKind('youtube#liveBroadcast');

$broadcastsResponse = $youtube->liveBroadcasts->insert('snippet,status,contentDetails', $broadcastInsert, array());

其中 $liveStreamingApi->setLiveBroadcasts 设置 https 中的所有基本范围(force-ssl、youtube、youtubepartner) $youtube->liveBroadcasts->insert 抛出上述错误

【问题讨论】:

你能分享你的代码和你的整个请求吗? 我们也遇到了同样的问题,我们的配额远未接近容量 这里也一样,只有 168 个请求在测试创建了大约 10 个直播后显示。 【参考方案1】:

youtube API 有一个配额限制,限制了您在一天内可以提出的请求。默认配额值是每天 1000000,拆分为一整天。但是,每个 API 请求都会花费不同数量的配额点。如果您通过了配额限制,您将收到一条 LivePermissions 不足的错误消息。 您可以在此处查看您的配额使用情况: https://developers.google.com/youtube/v3/determine_quota_cost 但是您可以考虑插入请求大约需要 1600 个配额。

【讨论】:

我知道配额,并注意到计算器有它用于 Data Api,据说它是 Live Streaming API 的来源,但那里缺少一些点。例如我们知道视频上传的费用是多少,但流的费用是多少? 任何人都知道,肯定比插入视频要贵得多。我在开发我的应用程序时遇到了同样的问题。 Youtube 应该提供更多的文档,有一些未列出的请求,如绑定和转换,并且插入广播或流肯定有很大的配额。 在测试创建大约 10 个直播后,我的配额显示为 168。不确定我的配额是否显示为 true

以上是关于Youtube Live Streaming API 使用限制的主要内容,如果未能解决你的问题,请参考以下文章