YouTube的PHP API - Zend_Gdata_App_HttpException [英] YouTube PHP API - Zend_Gdata_App_HttpException

查看:211
本文介绍了YouTube的PHP API - Zend_Gdata_App_HttpException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作网站,它使用的YouTube API。一切都很好,但今天我注意到在使用该API,我得到错误:

I've got a working website, which uses youtube api. Everything was fine but today I noticed I get error while using this api:

Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 403 <?xml version='1.0' encoding='UTF-8'?><errors><error><domain>yt:quota</domain><code>too_many_recent_calls</code></error></errors>' in /root/public_html/grabandrun.com/public/ZendGdata/library/Zend/Gdata/App.php:700 Stack trace: #0 /root/public_html/grabandrun.com/public/ZendGdata/library/Zend/Gdata.php(221): Zend_Gdata_App->performHttpRequest('GET', 'http://gdata.yo...', Array, NULL, NULL, NULL) #1 /root/public_html/grabandrun.com/public/ZendGdata/library/Zend/Gdata/App.php(861): Zend_Gdata->performHttpRequest('GET', 'http://gdata.yo...', Array) #2 /root/public_html/grabandrun.com/public/ZendGdata/library/Zend/Gdata/App.php(754): Zend_Gdata_App->get('http://gdata.yo...', NULL) #3 /root/public_html/grabandrun.com/public/ZendGdata/library/Zend/Gdata/App.php(205): Zend_Gdata_App->importUrl('http://gdata.yo...', 'Zend_Gdata_YouT...', NULL) #4 /root/public_html/grabandrun.com/public/ZendGdata/library/Zend/Gdata.php( in /root/public_html/grabandrun.com/public/ZendGdata/library/Zend/Gdata/App.php on line 700

我的code看起来在某种程度上是这样的:

my code looks somehow like this:

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Uri_Http');
$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();
$query->setQuery($searchTerms);
$query->setStartIndex($index2);
$query->setMaxResults(10);
$query->setOrderBy($order);

$videoFeed = $yt->getVideoFeed($query);

foreach ($videoFeed as $videoEntry) {
    $videoThumbnails = $videoEntry->mediaGroup->thumbnail[0]->url;
    $title = $videoEntry->mediaGroup->title;
    $vidId = $videoEntry->getVideoId();
    $vidDescription = $videoEntry->mediaGroup->description;
    $duration = $videoEntry->mediaGroup->duration->seconds;
    $rating = round($videoEntry->rating->average,1)." out of 5";
    echo "info...";
}

有趣的是,它有时工作和某个不......我真的不知道为什么,任何帮助AP preciated,谢谢。

Funny thing is that it sometime works and sometime does not... I don't really know why, any help appreciated, thanks.

推荐答案

正如评论所说,我只是来限制访问,并降低呼叫。谢谢光荣。

As stated in comments, I just had to limit the access and lower the calls. Thanks Slava.

这篇关于YouTube的PHP API - Zend_Gdata_App_HttpException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆