I'm using the Zend Framework (php) and I'm trying to retrieve a list of the most recent videos uploaded by all of the users I subscribe to. Similar to what you would see if you visit your Subscriptions page on youtube.com.
I can make a request using getSubscriptionFeed() for all the users I subscribe to. Then I can iterate through each one and make a request for getUserUploads() then pop off the first item, but it takes forever and seems like a lot of unnecessary work. There must be a single query I can make with all of the user names I want to find.
Any ideas开发者_JAVA百科?
Thanks, Howie
In case anyone is interested:
The most recent version of the Zend Framework (1.11.10) does not include the all-important method to retrieve the newest videos from your subscriptions as documented here on google's site.
So I simply added:
/**
* 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');
}
to the YouTube.php document in the Zend/GData directory on line 561 (after the getSubscriptionFeed method).
Now I can call getNewSubscriptionVideos method and pass it a username or 'default' and it will return an array of VideoEntities that can be accessed using:
$raw_new_subscription_videos = $_youtube->getNewSubscriptionVideos($username);
foreach ($raw_new_subscription_videos as $video)
{
$title = $video->getVideoTitle();
// etc.
}
Hope this helps anyone else who is as lost as I was for the past few hours.
Howie
精彩评论