获取“402 要求付款"使用 Youtube 的 iframe API 嵌入视频 [英] Getting "402 Payment Required" using Youtube's iframe API to embed videos
问题描述
我正在使用 youtube 的 iframe API 在一个网站上嵌入视频,一次一个,从 reddit 获取视频列表.
I am using youtube's iframe API to embed videos, one at a time, on a website that gets lists of videos from reddit.
昨天一切正常,但是今天当 iframe 调用 http://www.youtube.com/get_video_info[...] 并且视频无法加载时,我收到402 Payment Required".这种情况每隔一段时间就会发生一次,感觉就像某种节流.我认为这可能与我今天所做的代码的一些更改有关,但是当我恢复到昨天的代码时,我遇到了同样的错误.
Yesterday everything was working fine, however today I am getting "402 Payment Required" when the iframe makes a call to http://www.youtube.com/get_video_info[...], and the videos doesn't load. This happens every once in a while, it feels like some sort of throttling. I thought it may be related to some changes to the code I've done today, but I was getting the same errors when I reverted to yesterday's code.
我相信 GET 请求来自 Youtube 的 HTML5 播放器,在调用新的 YT.Player 后,它被加载到 iframe 中:
I believe the GET requests originates from Youtube's HTML5 player, which is loaded in the iframe, after calling new YT.Player:
player = new YT.Player(
'player', {
playerVars: {
// 'controls': 0 // TODO: Hide controls.
},
videoId: vidid,
events: {
'onReady': onPlayerReady,
'onStateChange': checkState
}
}
GET http://www.youtube.com/get_video_info?html5=1&video_id=bV3W1a_rY7k&eurl=http%3A%2F%2Flocalhost%2Fderp.html&el=embedded&hl=zh_CN&splay=1响应:402 需要付款
GET http://www.youtube.com/get_video_info?html5=1&video_id=bV3W1a_rY7k&eurl=http%3A%2F%2Flocalhost%2Fderp.html&el=embedded&hl=en_US&splay=1 Response: 402 Payment Required
您可以在此处查看示例:
You can see the example live here:
推荐答案
在谷歌上搜索了一下之后,我发现了这个问题的参考这里.
After googling for a bit I found a refernce to this problem here.
youtube 似乎劫持了 402,意思是由于使用率高,youtube 需要验证码才能解决."
It seems that youtube has hijacked the 402 to mean "Due to high usage, youtube requires a CAPTCHA to be solved."
这篇关于获取“402 要求付款"使用 Youtube 的 iframe API 嵌入视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!