1

我正在使用 Zend 框架 (php),我正在尝试检索我订阅的所有用户上传的最新视频列表。类似于您访问 youtube.com 上的订阅页面时看到的内容。

我可以使用 getSubscriptionFeed() 为我订阅的所有用户发出请求。然后我可以遍历每一个并请求 getUserUploads() 然后弹出第一个项目,但这需要很长时间,而且似乎有很多不必要的工作。必须有一个我可以使用我想要查找的所有用户名进行的查询。

有任何想法吗?

谢谢,豪伊

4

1 回答 1

2

如果有人感兴趣:

Zend Framework (1.11.10) 的最新版本不包括从您的订阅中检索最新视频的最重要方法,如google网站上所述。

所以我简单地补充说:

/**
 * Retrieves a feed of a user's subscriptions
 *
 * @param string $user (optional) The username of interest
 * @param mixed $location (optional) The URL to query or a
 *         Zend_Gdata_Query object from which a URL can be determined
 * @return Zend_Gdata_YouTube_VideoFeed The newest video for each subscription
 */
public function getNewSubscriptionVideos($user = null, $location = null)
{
    if ($user !== null) {
        $uri = self::USER_URI . '/' . $user . '/newsubscriptionvideos';
    } else if ($location instanceof Zend_Gdata_Query) {
        $uri = $location->getQueryUrl();
    } else {
        $uri = $location;
    }
    return parent::getFeed($uri, 'Zend_Gdata_YouTube_VideoFeed');
}

到 Zend/GData 目录中的 YouTube.php 文档的第 561 行(在getSubscriptionFeed方法之后)。

现在我可以调用getNewSubscriptionVideos方法并将用户名或“默认”传递给它,它将返回一个可以使用以下方法访问的 VideoEntities 数组:

$raw_new_subscription_videos = $_youtube->getNewSubscriptionVideos($username);

foreach ($raw_new_subscription_videos as $video)
{
  $title = $video->getVideoTitle();

  // etc.
}

希望这可以帮助其他像我过去几个小时一样迷路的人。

豪伊

于 2011-09-08T04:46:35.607 回答