Please tell me if I’m understanding correctly. (because I might not be.)
- User posts something on my site. (He checked “also post to Facebook”.)
- Client sends an AJAX POST request to my server, and my server inserts the record in my database.
- The server realizes the the facebook user access token is expired, so it sends the response back to the client, while storing the post in a session.
- The client does a
window.location.replace(facebook_oauth_dialog_url) - Then the user will see a sudden “flash”, going to Facebook, then coming back to the website. My server picks up the new access token.
- My server checks the session to see what should be posted to Facebook. And then, it uses the new access token to post that to Facebook.
Is it really this tedious? Why can’t I renew the app server-side without the user going through the dialog?
My entire site is Backbone.js. That means, it’s one big page. I can’t jump the user back and forth between Facebook and my website like this.
The idea is to make use of the Facebook JS-SDK methods:
FB.getLoginStatus())FB.apimethod oraccess_tokento your server to complete the post process thereFB.login()methodHere’s a quick example (with a Live Demo!) for you to get started: