G+ shutdown, Google Apps Script and Firebase to the rescue!
This is the first post of a serie going into some technical details about a migration project for G+ communities — if you want to retrieve G+ data, take a look at this tutorial.
Google+ will be shutdown for consumers in April 2019. It won’t impact that many people but G+ was (still is…) the main place to discuss some topics, like Google Apps Script. Over the years, some G+ communities accumulated a lot of valuable knowledge which might totally disappear with the shutdown. Google usually provides ways to retrieve content when it is shutting down a product, via the Google Takeout initiative but here it seems people will only be able to retrieve their own content (ie: the posts they have created) not all the content posted on a community. Thus I began to investigate the possibility of retrieving this content.
Retrieving content via the G+ API and Google Apps Script
Google offers an API to retrieve content from G+ but at first glance it seems not possible to use it to retrieve content from a community. Luckily, similar to other Google APIs, you can perform a search / query to retrieve specific content out of G+ (eg: find all posts containing a specific keyword) and you can use the same advanced search operators usable in the G+ web app (very similar to the Gmail API, which also lets you use the same advanced search operators in the API and in the app, like “is:unread cc:me”).
Note: those advanced search operators for G+ are quite new - they were announced only a year ago, in December 2017. Before it was simply not possible to retrieve content from a community via the API.
So, we have an API to retrieve the content we want. And Google Apps Script is a perfect tool to make calls to this API with ease (it offers a web-based code editor, runs your code on Google servers and handles all the authentication/ authorization steps required to call a Google API like the G+ API).
Storing and displaying content with Firebase
Ok, we are able to retrieve all posts, comments, +1… from a community. But it’s all in a JSON format, not very friendly to look at... So, where should we store it and what could we use to display it? Firebase!
- Storing the data (posts, comments, +1s) is super easy with the Firebase Realtime Database. This database is basically a big JSON store and we can simply push the raw content retrieved via the API without any transformation.
- We can then use Firebase Hosting to display the posts stored in the database. I took the liberty to copy the CSS of the G+ web app, so we can really feel at home :)
- We will also need to retrieve the images published within posts in G+. They are currently hosted on Google servers and might be deleted as part of the G+ shutdown. Luckily Firebase Storage will be perfect for that.
- We could also decide to do more than an archive and offer real, live and usable copies of existing communities. For that people should be able to authenticate themselves via their Google account and continue to post, comment and +1 posts in their own name (as shown in the previous screenshot). Firebase Authentication is perfect for that.
That’s all for today. You can see a live example of the exported Apps Script community here: https://apps-script-community-archive.firebaseapp.com/
Here’s also a tutorial to make your own export with Apps Script and Firebase.
And if you want to contribute, everything is on GitHub.
I will continue this serie with other articles explaining how I copied the G+ look’n’feel, why I used Glitch to help people do their own export, how we can use Firebase rules to recreate a live community without any server side code and much more!
Second article of this serie is published! — Deploying with(out) a Glitch