Title: Facebook API Request from Firebase Server
Tags: ios;facebook-graph-api;firebase;firebase-realtime-database
Question: I am creating an iOS app which displays a public Facebook post data in the app with some other activities on those post data. As of now, I am sending FB graph api requests to fetch post data from my app itself. Like:
login with Facebook and fire an API get request to that group.
store the response JSON data to Firebase database.
fetch data from Firebase database and display it in app.
The problem with this is, If a user does a Facebook login-in, in the app, API requests will be fired from his/her authentication.
I want to fetch group post data from my Facebook authentication only, so that the data will be available to non logged in users also.
So, is it possible in Firebase to write a server script that will fetch data, periodically into Firebase Database, always with my authentication. And later on I can receive data from that database and display it to users.
send API req from server                     fetch data from DB
Facebook Graph API <-------------------Firebase Database ---------------------&gt; iOS App

Here is the accepted answer: This is definitely possible. Have your server code use the Facebook Authentication API to sign in Facebook and the Firebase Authentication API to sign in to the database.
Then read the posts from Facebook and write them into the (secured) location in your database. Your iOS can then simply read this location. This essentially comes down to pattern 2 as described in this blog post on common Firebase application architectures.
Comment for this answer: thank you for your reply.. But how do I add server code in Firebase, by creating a web app in the dashboard?
Comment for this answer: I got answer in this post http://stackoverflow.com/questions/21653378/how-would-i-run-server-side-code-in-firebase


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:06/11/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ios><facebook-graph-api><firebase><firebase-realtime-database>', 'Title': 'Facebook API Request from Firebase Server', 'ViewCount': 579, 'id': 37769191, 'user_AboutMe': '', 'user_AccountId': 2662158.0, 'user_DisplayName': 'triandicAnt', 'user_Reputation': 1258.0, 'user_Views': 199.0, 'user_id': 2301570.0}}