Sunday, 8 September 2013

How to get trending Youtube videos using the API

How to get trending Youtube videos using the API

My goal is to get a list of all trending videos, and also a list of my
favourite videos.
I don't want to use the RSS feeds because they seem to have very small
limits on the amount of request you can make, where the API is generous.
I have created a service account on the Google API Console and here is the
code I am using:
require('analytics/Google_Client.php');
require('analytics/contrib/Google_YouTubeService.php');
$client = new Google_Client();
$client->setApplicationName('xx');
$client->setAssertionCredentials(
new Google_AssertionCredentials(
'xx@developer.gserviceaccount.com',
array('https://www.googleapis.com/auth/analytics.readonly'),
file_get_contents('xx.p12')
)
);
$client->setClientId($analytics_client_id);
$client->setAccessType('offline_access');
$youtube = new Google_YoutubeService($client);
Up to here everything seems to be working, but I cant find any
documentation on how to use $youtube and what functions are availible -
All I can find is how to search YouTube for videos.
Thanks.

No comments:

Post a Comment