To get the revision history of your resource in your Google Docs using Google Apps Script, you can use Google DocsList API with Google oAuth and URLFetch App. References:
Here is a quick code which will return the revision history entries in the form of JSON. You can use this JSON to get the different fields in revision history. //Get revison history // resource_id is the ID of the resource from Google Docs function getRevisionHistory(resource_id){ //Scope var scope = 'https://docs.google.com/feeds/'; //Get Google oAuth Arguments var fetchArgs = googleOAuth_('docs', scope); //Set the fetch method fetchArgs.method = 'GET'; //Feed URL var url = scope + 'default/private/full/'+resource_id+'/revisions?v=3&alt=json'; var urlFetch = UrlFetchApp.fetch(url, fetchArgs); //Get the json of revision history entry var jsonFeed = Utilities.jsonParse(urlFetch.getContentText()).feed.entry; //return the revison history feed return jsonFeed } //Google oAuth //Used by getRevisionHistory function googleOAuth_(name,scope) { 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"}; } |
URLFetch and oAuth >