我正在使用 Zend Youtube API。我查询了一个提要,报告它总共有 886 个条目,但是当我获取所有提要并迭代时,实际数字是 782。
实际上是否存在不匹配,或者我忽略的代码中是否存在一些愚蠢的错误?
片段(debug() 只是一个方便的报告功能):
$query = $yt->newVideoQuery($queryUrl);
$query->setMaxResults(50); //Max allowed, to reduce API hits
$feeds = array();
try {
$feed = $yt->getVideoFeed($query);
$totalResults = $feed->getTotalResults(); //For debug
$feeds[] = $feed;
$totalFromFeeds = sizeof($feed); //For debug
while ($feed = $feed->getNextFeed()) {
$feeds[] = $feed;
$totalFromFeeds += sizeof($feed); //For debug
}
} catch (Zend_Gdata_App_Exception $e) {
debug("$e"); //For debug
//Just means no more feeds; do nothing
}
$numFeeds = sizeof($feeds); //For debug
$entries = array();
foreach ($feeds as $feed) {
foreach ($feed as $entry) {
$entries[] = $entry;
}
}
$numEntries = sizeof($entries); //For debug
debug("According to feed, [$totalResults]; sizeof entries = [$numEntries]
Num Feeds: $numFeeds; totalfromfeeds: $totalFromFeeds");
调试输出:
exception 'Zend_Gdata_App_Exception' with message 'No link to next set of results found.
According to feed, [886]; sizeof entries = [782]
Num Feeds: 16; totalfromfeeds: 782
感谢您的任何指点,
克里斯