If you want to get all media items of the album. You can use this function.
Thank you for helpful library.
SearchMediaItemList(id_album) { var mediaItems, pageToken, params, res, url; url = "https://photoslibrary.googleapis.com/v1/mediaItems:search"; var payload = { 'albumId': id_album }; params = { method: 'post', muteHttpExceptions: true, headers: { Authorization:Bearer ${this.accessToken} }, payload : payload }; mediaItems = []; pageToken = ""; params.url = url; while (true) { payload.pageToken = pageToken ? pageToken : ''; params.payload = payload; res = UrlFetchApp.fetchAll([params])[0]; r = JSON.parse(res.getContentText()); if (res.getResponseCode() !== 200) { throw new Error(res.getContentText()); } Array.prototype.push.apply(mediaItems, r.mediaItems); pageToken = r.nextPageToken; if (!pageToken) { break; } } return mediaItems; }
If you want to get all media items of the album. You can use this function. Thank you for helpful library.
SearchMediaItemList(id_album) { var mediaItems, pageToken, params, res, url; url = "https://photoslibrary.googleapis.com/v1/mediaItems:search"; var payload = { 'albumId': id_album }; params = { method: 'post', muteHttpExceptions: true, headers: { Authorization:
Bearer ${this.accessToken}}, payload : payload }; mediaItems = []; pageToken = ""; params.url = url; while (true) { payload.pageToken = pageToken ? pageToken : ''; params.payload = payload; res = UrlFetchApp.fetchAll([params])[0]; r = JSON.parse(res.getContentText()); if (res.getResponseCode() !== 200) { throw new Error(res.getContentText()); } Array.prototype.push.apply(mediaItems, r.mediaItems); pageToken = r.nextPageToken; if (!pageToken) { break; } } return mediaItems; }
Full code at: https://pastebin.com/qg1fQsfW