I made the following
var NAME = 'youtube';
var SCOPE = 'http://gdata.youtube.com';
//var URL = "https://picasaweb.google.com/data/feed/api/user/default";
var URL = "http://gdata.youtube.com/feeds/api/users/default/favorites?v=2";
function doGet(e) {
var app = UiApp.createApplication().setTitle("youtube");
var data = UrlFetchApp.fetch(URL, googleOAuth_()).getContentText();
var xmlOutput = Xml.parse(data, false);
var favorites = xmlOutput.getElement().getElements('entry');
app.add(app.createLabel(favorites.length.toString()))
for(var i = 0; i < favorites.length; i++){
app.add(app.createLabel(favorites[i].getElement('title').getText()))
//var testf = favorites[i].getElement('http://gdata.youtube.com/schemas/2007#favorite','href');
}
return app;
}
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'};
}
To get the title of the favorite videos it works fine
But I can´t find the way how to get to the url of the favorite video.
where can I find that in the documentation?
And than another question, when I try to execute the script
with another google account it still gives the error:
Authorization is required to perform that action
Isn´t the googleOAuth_()
funcion taking care of that?