Search code examples
phpyoutube-apizend-gdata

Get related youtube videos by a certain uploader


For a youtube brand channel I need to find related videos only from the owner of that channel.

I use the Zend_Gdata_YouTube class. To search for videos by category or keywords I'am using the function getVideoFeed:

$this->yt->getVideoFeed('http://gdata.youtube.com/feeds/api/users/'.self::UPLOADER.'/uploads?category=' . $category)

for related videos I'am creating a new video query and set the feed type to related:

$ytQuery = $this->yt->newVideoQuery();
$ytQuery->setFeedType('related', $videoId);

I've searched everywhere but can't figure out how to set the uploader in the video query, nor how to create the right link for the video feed. However, there is the method setUploader that only accepts partner as parameter.

Is there any possibility to get related videos uploaded by a certain user, or do I have to write a function by my own?


Solution

  • well, the answer is a mix of all parts I already used and tried:

    $query = $this->yt->newVideoQuery();
    
    $query->setFeedType('related', $videoId);
    $query->setMaxResults(4);
    $query->setAuthor(self::UPLOADER);
    
    $feed = $this->yt->getVideoFeed($query);
    

    the direct API call would be:

    $url = 'http://gdata.youtube.com/feeds/api/videos/'.$videoId.'/related?max-results=4&author='.self::UPLOADER;