Getting “402 Payment Required” using Youtube's iframe API to embed videos

自作多情 提交于 2019-12-13 02:35:51

问题


I am using youtube's iframe API to embed videos, one at a time, on a website that gets lists of videos from reddit.

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.

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=en_US&splay=1 Response: 402 Payment Required

You can see the example live here:

http://ozi.ca/#videos


回答1:


After googling for a bit I found a refernce to this problem here.

It seems that youtube has hijacked the 402 to mean "Due to high usage, youtube requires a CAPTCHA to be solved."




回答2:


I agree with Trent. I came across this problem when trying to get video info thru MPS Youtube and realized it was because I was connecting through a VPN, so google was getting a ton of requests from the same IP and required the Captcha. As soon as I turned off the VPN, I was able to get video info




回答3:


The resolve this problem, navigate your browser to www.youtube.com and solve the captcha that you see there. Once you do that, you will no longer see the error.



来源:https://stackoverflow.com/questions/14107455/getting-402-payment-required-using-youtubes-iframe-api-to-embed-videos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!