From 11a25a2f09ec5c9ae6581bb441fd2f9dacba0fd6 Mon Sep 17 00:00:00 2001 From: z1c0 Date: Sat, 8 Oct 2016 16:03:01 +0200 Subject: [PATCH] albumId ption The "options" object passed to "getPhotos" now looks for an "albumId" property and retrieves only photos for this specific album. Updated sample code. Implemented feedback --- README.md | 3 ++- src/picasa.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4282958..059cf47 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ const picasa = new Picasa() const options = { maxResults : 10 // by default get all + albumId : "6338620891611370881" // by default all photos are selected } picasa.getPhotos(accessToken, options, (error, photos) => { @@ -109,4 +110,4 @@ MIT © Play around https://developers.google.com/oauthplayground/?code=4/usq8QmuezR3Au_0UKyj9-UXmf6Bw_ij8KFWgIziYbpM# -Picasa Docs https://developers.google.com/picasa-web/docs/2.0/developers_guide_protocol +Picasa Docs https://developers.google.com/picasa-web/docs/2.0/developers_guide_protocol \ No newline at end of file diff --git a/src/picasa.js b/src/picasa.js index 1501e73..71c1861 100644 --- a/src/picasa.js +++ b/src/picasa.js @@ -112,10 +112,12 @@ function getPhotos (accessToken, options, callback) { if (options.maxResults) accessTokenParams['max-results'] = options.maxResults + const albumPart = options.albumId ? `/albumid/${options.albumId}` : ''; + const requestQuery = querystring.stringify(accessTokenParams) const requestOptions = { - url : `${PICASA_SCOPE}${PICASA_API_FEED_PATH}?${requestQuery}`, + url : `${PICASA_SCOPE}${PICASA_API_FEED_PATH}${albumPart}?${requestQuery}`, headers: { 'GData-Version': '2' }