Managing social networks and App APIs for Events Ethiopia

We recently released our app on Google Play and App Store. If you haven’t seen it already, go download!
Android — https://play.google.com/store/apps/details?id=com.master.deuce
IOS — https://itunes.apple.com/us/app/events-ethiopia/id1071603724?ls=1&mt=8
Events Ethiopia has over 14K Twitter followers and over 2K Facebook Fans. We have been posting events on our social networks for over 6 years now (Long time ;) ). We deliver event news to our users living in Addis Ababa and abroad (Especially Ethiopian diaspora community around the world). When we started developing our Apps, it was very critical for us to maintain consistency in publishing events to both social network and the app. For this, we needed to design an admin console that publishes content to all of our channels and reduces the burden of managing our product.

Calling our backend API is very trivial, but posting to our social networks (FB/Twitter) might require some effort. To publish a story on Facebook, you need to have a valid access token which you obtain after authenticating your application with Facebook.
This poses a serious workflow issue.
- Admin must authenticate with FB/Twitter/Google+/.. every time they want to make a single post.
- If authentication fails (for any reason), the event won’t be posted and most importantly we won’t have any retry mechanisms in place to handle the failure.
So we moved the code that handles social networks to the backend. We don’t want our client side code to worry about authentication at this stage for a number of reasons. First, the admin must log in with multiple social networks before posting anything. Currently, we have Twitter and Facebook, but adding support for an extra network will be painful. It would be insane to ask an administrator to log in with 3 social networks to make a single entry to the system (ouch !!!!). Secondly, maintaining code will be much easier since an admin will have one single entry API for managing everything. (Basically a god API!).
So, we designed the following system.

One of the first things the admin console does is check if we have a valid access token on our database. This access token is saved into our database whenever someone from our team authenticates with FB/Twitter. This process is separate from the above diagram and is only done every three months (Depends on the expiration date of the token). If the token is valid, we can go ahead with posting the event to Facebook/Twitter. If not, we save the event on our task queue. Queuing events allows us to process them later when we obtain a valid access token.
Whenever we have a task on our queue, we immediately email administrators instructing them to re-login. Such process will refresh our tokens and we regain our prior capabilities back.
After this, we span a new service.

Event queue processor picks up these events and posts them one by one. Retry limit is three. If an event fails to be posted for more than three times, it will automatically be rejected.
That’s it. This is how we manage our backend API’s and our social network at the same time (with less pain of course ;) ). If you have any suggestions, please drop us a comment.
Ta ta