Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
417 views
in Technique[技术] by (71.8m points)

Youtube Data V3 resulting in 403

There's been some changes made to the API since I used it last. This is the way I've successfully used it in the past:

    if($host == 'youtube.com'){
        /* Long YT link.  It will be a GET var. */
        parse_str("$query",$vidArray);
        $ytStatusURL = 'https://www.googleapis.com/youtube/v3/videos?id='.$vidArray['v'].'&key=AIzaS...EQ5rN4czs&part=snippet';
        $json = file_get_contents($ytStatusURL);
        $obj = json_decode($json, true);
        $ytStatus = $obj[pageInfo][totalResults];
        if($ytStatus == '1'){
            $embed_type = 'youtube';
            $vid_string = substr($vidArray['v'], 0, 11);
            $vidKey['a'] = $embed_type;
            $vidKey['b'] = $vid_string;
            return $vidKey;
        }
    }

Which now results in:

 {
   "error": {
     "code": 403,
     "message": "The request cannot be completed because you have exceeded your u003ca href="/youtube/v3/getting-started#quota"u003equotau003c/au003e.",
     "errors": [
       {
         "message": "The request cannot be completed because you have exceeded your u003ca href="/youtube/v3/getting-started#quota"u003equotau003c/au003e.",
         "domain": "youtube.quota",
         "reason": "quotaExceeded"
       }
     ]
   }
 }

So I went to check on how many requests have been made:

YouTube Data API v3 Requests: 3 Errors: 100 Latency: 49 Latency, 95%: 63

Either 3 requests is too many or something has changed to cause my api key to start failing and Google's not giving a ton of info on why.

I've followed all the provided links and Googled a bunch but I can't figure out why it's not working. What do I need to do to raise the API key to something more than zero allowed requests?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...