List of JSON files in Google Drive

I have a code snippet that takes a list of photos in a PICASA public album and builds the list used in the slider. The simplified code is as follows:

var usrID = "555555555555555555555"; var albID = "5555555555555555555"; $.getJSON( "https://picasaweb.google.com/data/feed/base/user/"+usrID+"/albumid/"+albID+"?alt=json&kind=photo&hl=en_US&callback=?", function(data) { var picAlbumLst = '<ul id="slider">'; $.each(data.feed.entry, function(i, element) { var picUrl = element["media$group"]["media$thumbnail"][0].url; picAlbumLst += ( '<li style="text-align:center">'+ ' <img src="'+picUrl+'"/>'+ '</li>' ); }); picAlbumLst += "</ul>\n"; ... }); 

I'm going to transfer my photos from Picasa to Google Drive. Is there a way to make a request similar to my old PICASA to get URLs from Google Drive (anonymous user)? The closer the syntax is, the easier the port will be (I have it everywhere).

0
source share
1 answer

As before, I asked a question because it was too lazy to work on this more difficult. But I managed to solve it at the end. So here is the solution for Google Drive:

1 / Perform all OAuth 2.0 dances to access the [IMAGE_FOLDER_ID] folder. The application must be authenticated / authorized, even if the folder is open.

2 / don't forget to download the Google Drive service API

gapi.client.load ('drive', 'v2', makeRequestCB)

... and here's a loop to get the file urls

 function makeRequestCB() { gapi.client.drive.files.list({ 'q': '"[IMAGE_FOLDER_ID]" in parents', 'fields' : 'items/id' }).execute(function(resp) { var picAlbumLst = '<ul id="slider">'; for (i=0; i<resp.items.length; i++) { var id = resp.items[i].id; picAlbumLst += ('<li><img src="https://docs.google.com/uc?id='+id+'"/></li>'); } picAlbumLst += "</ul>\n"; }); } 

Hope this helps.

0
source

Source: https://habr.com/ru/post/1209327/


All Articles