How to access a Google Photos shared album - google-api

I posted this as an answer to a related question but it was deleted by a moderator, so I'm posting this now as a question. The related question is
Accessing shared albums from Google Photos
I am trying to access a Google Photos shared album using JavaScript. Public albums created with Picasa are easier to deal with using the Picasa Web Albums Data API.
I've developed a peculiar solution parsing the HTML contents of a shared album URL, such as
https://photos.google.com/share/<album>?key=<key>
The parsing function is
function getgooglephotos2(result)
{
var r2 = result.substr(result.search("AF_initDataCallback\\("));
var r3 = r2.substr(0, r2.search("https://video"));
var img = r3.search("https:");
while (img != -1) {
var r4 = r3.substr(img);
var imgend = r4.search("\"");
var r5 = r4.substr(0, imgend);
// r5 contains an image url
r3 = r4.substr(imgend);
img = r3.search("https:");
}
}
I would prefer a cleaner approach. Any idea?
Thanks.
PS: it seems that using authentication, I can reach a Google Photos shared album, but I am trying to implement a solution that doesn't require authentication for shared (public) albums. Here's a link
https://adodson.com/hello.js/demos/albums.html
A simpler approach to test this is
Authenticate on picasa and fetch your userid
https://picasaweb.google.com
After authentication you will reach
https://get.google.com/albumarchive/<userid>?source=pwa
Get your album list using the Picasa Web Albums Data API
https://picasaweb.google.com/data/feed/api/user/<userid>

I'm just developing app that doesn't require authentication. Anyway somehow you need to point out which album should be displaying. In my project I'm using Firebase to store URLs to shared albums. Then I request the URL and get photos using regex. To retrieve the photos I used this tutorial:
https://medium.com/#ValentinHervieu/how-i-used-google-photos-to-host-my-website-pictures-gallery-d49f037c8e3c
At the moment there is no way to access shared albums directly from Google Photos without authentication.

Related

How to use Google Picker with Google Drive using flutter

I can't find any resource to embed google Picker in a flutter to upload a doc to Google drive. Can any provide me with an example of how to integrate Google Picker to Flutter?
Same issue here, you can use file_picker:
final result = await FilePicker.platform.pickFiles();
It will navigate user to an UI for selecting files including other app's files, i.e. google drive.
BTW, you should request permissions before picking the file:
final googleSignIn = GoogleSignIn(scopes: []);
await googleSignIn.signIn()
// request when you need it!
await googleSignIn.requestScopes([SheetsApi.spreadsheetsScope])
Found similar question here: File Picker for Google Drive Rest API for Android

Download my own private albums using Flickr API

I'm trying to download my own flickr albums using the API. I'm using the flickr.rb gem here
I am creating a new object using this:
#flickr = Flickr.new({api_key: 'xxxxx', shared_secret: 'xxxxx', verify_ssl: false})
And then I'm using:
p = #flickr.photoset(photoset_id)
Where I pass the id of my photoset I want to download.
I keep getting the error:
/.rvm/gems/ruby-2.2.5/gems/flickr.rb-1.2.1/lib/flickr.rb:199:in `request': Photoset not found (RuntimeError)
What is the correct way to authenticate to Flickr and download my photos? I don't want to build any UI, just want a command line app to do this. Is there some URL I need to hit in the browser to authorize the app and grant permissions? The documentation is really sparse and doesn't give any examples.
Update: In response to #r-f-nelson
The 'user' as retrieved:
#Flickr::User:0x007fd8cea6ad98 #id="29916617#N02", #username="taraporefarhad", #client=#<Flickr:0x007fd8cf09fc68 #host="https://api.flickr.com", #api="/services/rest", #verify_ssl=false, #api_key="36705xxxxxxxxxxxxxxx", #shared_secret="xxxxxxxxxxxxxx", #auth_token=nil, #ca_file=nil
The 'flickr' client object:
#Flickr:0x007fd8cf09fc68 #host="https://api.flickr.com", #api="/services/rest", #verify_ssl=false, #api_key="36705xxxxxxxxxxxxxxx", #shared_secret="xxxxxxxxxxxxxx", #auth_token=nil, #ca_file=nil, #user=#
Flickr::User:0x007fd8cea6ad98 #id="29916617#N02", #username="taraporefarhad", #client=#<Flickr:0x007fd8cf09fc68 ...
The Photoset object:
#Flickr::Photoset:0x007fd8cf06c9d0 #id="72157638843727066", #api_key=nil, #client=#<Flickr:0x007fd8cf06c8b8 #host="https://api.flickr.com", #api="/services/rest", #verify_ssl=true, #api_key=nil, #shared_secret=nil, #auth_token=nil, #ca_file=nil
/.rvm/gems/ruby-2.2.5/gems/flickr.rb-1.2.1/lib/flickr.rb:199:in `request': Invalid API Key (Key has invalid format) (RuntimeError)
Note above that the "photoset" object has a different flickr client object id and NO shared secret and API key! Not sure how that's happening since I'm using the same client and user objects to get the photoset as well.
Assuming you are successfully connecting to Flickr's API, you can browse your own photosets like so:
user = flickr.users('you#yourflickraccount.com')
photosets = user.photosets
From there you can iterate through your photosets to find the correct one. I'm guessing whatever id you're using is not the actual photoset_id that the Flickr API uses.

Google Sheets API: How to "publish to web" for embeddable sheet?

If I wanted to publish a Google Sheets spreadsheet so I could embed it on a page within an iframe, I would manually do the following:
Navigate to Google Drive
Open a spreadsheet
File > Publish To Web > Embed > Copy the generated iframe link into an html file
How would I programmatically achieve the above through the Google Sheets API using JavaScript on the front end? I'm generating spreadsheets on the fly in my application and want to immediately embed them on the page once created.
Once the sheet is created, I can dynamically create an iframe element with the necessary attributes (the sheets ID, among others). That throws an error. From this question, it looks like a sheet needs to have a published: true attribute or something, but that requires using the Drive API - I'm trying to avoid that. Is this possible to handle only through the Sheets API?
After searching through the entire Sheets API, googling, and just general soul-searching, I had no choice but to include the Drive API and use it to do my bidding. Here's the solution I came up with. Hope this helps someone else out there!
Used this script from Google for the client-side JS library in the index.html file:
<body>
...
<script type="text/javascript" src="https://apis.google.com/js/client.js"></script>
</body>
Then for the JS stuff:
// Cache the api's into variables.
var sheets = gapi.client.sheets;
var drive = gapi.client.drive;
// 1. CREATE NEW SPREADSHEET
sheets.spreadsheets.create({
properties: {
title: 'new-sheet'
}
}).then(function(newSpreadSheet) {
var id = newSpreadSheet.result.spreadsheetId;
// 2. PUBLISH SPREADSHEAT VIA DRIVE API
drive.revisions.update({
fileId: id,
revisionId: 1
}, {
published: true, // <-- This is where the magic happens!
publishAuto: true
}).then(function() {
// 3. DISPLAY SPREADSHEET ON PAGE VIA IFRAME
var iframe = [
'<iframe ',
'src="https://docs.google.com/spreadsheets/d/',
id,
'/pubhtml?widget=true&headers=false&embedded=true"></iframe>'
].join('');
// We're using jQuery on the page, but you get the idea.
$('#container').html($(iframe));
});
});
As you have concluded, it is not possible through the Sheets API today and is only possible through the Drive API (using the PATCH https://www.googleapis.com/drive/v3/files/fileId/revisions/revisionId request, documented at https://developers.google.com/drive/v3/reference/revisions/update).

Facebook SDK iOS share photo ( FBSDKSharePhotoContent ) can not share applink

I'm trying to share a photo using FBSDKSharePhotoContent and make the applink works but I bang my head to make it works.
My app is mobile only so the photos are not hosted on any web site.
I use this code to share the photo:
let photo = FBSDKSharePhoto()
photo.image = currentHeaderImage
photo.userGenerated = false
let photoContent = FBSDKSharePhotoContent()
photoContent.photos = [photo]
photoContent.hashtag = FBSDKHashtag(string: "#Showflix")
photoContent.contentURL = NSURL(string: "applink...")
FBSDKShareDialog.showFromViewController(self, withContent: photoContent, delegate: nil)
I generated the applink using the Facebook Developer site interface.
The photo is corretly published on Facebook but there are no link in the post. If I click on the photo it only open a normal photo on facebook.
I tried also using photo.imageUrl, I tried also FBSDKShareDialog without success.
All I need is to share a photo on Facebook user wall and if someone clicks on this photo it should propose to open it in the mobile app.
Thanks for help

Attach image using Twitter Share link

Is it possible to attach an image to a tweet using the Twitter share link?
I'm using the following url to tweet but I can't find away to attach an image. The tweet has a link to the image but I want it attached to the tweet so someone can view the image while reading the tweet.
https://twitter.com/intent/tweet?hashtags=MyTag&url=http%3A%2F%2Ftest.com%2Fimage.png
Or would have to use the twitter api?
I would recommend using https://tweetinvi.codeplex.com/documentation which you can programmer directly with twitter.
// Publish with media
byte[] file = File.ReadAllBytes(filePath);
var tweet = Tweet.CreateTweetWithMedia("I love tweetinvi", file);
var imageURL = tweet.Entities.Medias.First().MediaURL;
// Publish with geo information
var tweet = Tweet.CreateTweet("Hello guys");
tweet.PublishWithGeo(-54.73, -64.2);
// Retweet
tweet.PublishRetweet();
I do not believe it is possible to upload media through the share link. Probably, a security decision by Twitter.
I suggest you try the twitpic API.

Resources