我有一个工作网站,它使用youtube api。一切都很好,但今天我注意到我在使用这个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
我的代码看起来像这样:
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...";
}
有趣的是,它有时是有效的,有时候却没有...我真的不知道为什么,任何帮助表示赞赏,谢谢。
答案 0 :(得分:0)
正如评论中所述,我只需限制访问权限并降低通话费用。谢谢Slava。