开发者

YouTube PHP API - Zend_Gdata_App_HttpException

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

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...";
}

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜