I have This script that lists my favorite videos of youtube using Oauth and the YTB API v2.
Now I would like to do the same with the YTB DATA API V3 and who knows an easy step ahaed is the YTB ANALYTICS API V1.
So I was looking for the URL that would get me to the favorites in V3.
var URL = "https://www.googleapis.com/youtube/v3/"
instead of
//var URL = "http://gdata.youtube.com/feeds/api/users/default/favorites?v=2";
Is that there a way to do it like this with the DATA API v3?
Or is it only possible to reach to the simple data with the long URL request with the API KEY as in the github example of @Arun Nagarajan
var url = 'https://www.googleapis.com/youtube/v3/activities?'
+'part=snippet&channelId=UC_x5XG1OV2P6uZZ5FSM9Ttw&maxResults=20&publishedBefore=2013-02-25T00:00:00.0Z'
+'&key='+API_KEY;
Here is the part of the code that I would like to use with the YTB API v3.
//var URL = "http://gdata.youtube.com/feeds/api/users/default/favorites?v=2"; works
var URL = "https://www.googleapis.com/youtube/v3/" // cant find it
function getFavoriteVideos()
{
var data = UrlFetchApp.fetch(URL, googleOAuth_()).getContentText();
var xmlOutput = Xml.parse(data, false);
var favorites = xmlOutput.getElement().getElements('entry');
Logger.log("a" + favorites.length.toString())
var a = favorites.length.toString()
for(var i = 0; i < favorites.length; i++)
{
favorites[i].getElement('title').getText()
Logger.log(favorites[i].getElement('title').getText())
}
}
The authentication
var NAME = 'youtube';
var SCOPE = 'http://gdata.youtube.com';
function googleOAuth_() {
var oAuthConfig = UrlFetchApp.addOAuthService(NAME);
oAuthConfig.setRequestTokenUrl('https://www.google.com/accounts/OAuthGetRequestToken?scope='+SCOPE);
oAuthConfig.setAuthorizationUrl('https://www.google.com/accounts/OAuthAuthorizeToken');
oAuthConfig.setAccessTokenUrl('https://www.google.com/accounts/OAuthGetAccessToken');
oAuthConfig.setConsumerKey('anonymous');
oAuthConfig.setConsumerSecret('anonymous');
return {oAuthServiceName:NAME, oAuthUseToken:'always'};
}