angular-easyfb
angular-easyfb copied to clipboard
Facebook canvas application
Hi, I've been using your library in many projects now and it is truly great!
I'm starting to work on a Facebook canvas app (an internal application that works inside the Facebook site through an iFrame).
I wonder if easyfb supports working with those kind of applications? From what I understand authentication is performed by getting a POST request signed_request.
Is this related to easyfb or not at all? Thanks
Hi @Urigo ,
Since the official Facebook JavaScript SDK works in Facebook canvas apps, I think easyfb
should work just fine as well.
The authentication part is covered by the official SDK, and might not be a problem.
But I haven't actually tested it at all. So please let me know if it works or not. :wink:
I've been working on a facebook app that uses this Library in a canvas app and it seems to work fine so far.. This is my first facebook canvas app so I've been learning alot from scratch but this library has been a massive help in developing the app. I'll share a link once it's done.
@jebarius How do you handle the POST request signed_request?
@Urigo I developed quite a few facebook applications, even ones with heavy form usage... The best course of action I can recommend, is that you should use ajax for sending and getting data from the back-end system, and if possible, completely dismiss the page refresh altogether...
@pc035860 Your library definitely works in a canvas application... at-least the FB.init, FB.ui, FB.api
functions do... haven't tried the directives so far, but for most of them, you need rendered pages on the source server to work properly as the require an url to analyze... and because of this most won't work within a canvas app.
@urigo did you ever figure this out?
@niiamon With a front-end angular app you don't need to mess with the signed request, because the JS SDK handles it.
With a backend (php) SDK the signed request is also handled within the SDK...
If you could provide a more detailed scenario maybe we could come up with a solution.
@blackfyre:
The goal is simple: in a front-end Angular app, how can I access either the signed_request
or the parsed result from the signed_request
?.
As I am running an Angular app within the context of a Facebook page chrome, I am interested in finding out which page my app is running within. That information is within the signed_request
. But since Facebook can't POST
the signed_request
to the Angular app, then there's no simple way for the Angular app to get access to the signed_request
and the information it contains.
In that scenario, apart from fronting the Angular app with a server that can receive the POST
, how else can the Angular app receive the data from Facebook?
@niiamon
The FB.getLoginStatus method call has the signed request in the JS SDK (official docs: https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus), but that's an encrypted string and you won't have access to it's content, and is only available after the user logs into the app...
Only a backend SDK can decipher the contents of the signed request, as it's sent via POST
to the url you've defined when creating your app, and that's also after the user tried to login into your app, and if this wasn't enough it requires the app secret code to decipher it. So this is basically for security reasons.
If you're looking for info on the page, you could look at the Graph API docs for the pages: https://developers.facebook.com/docs/graph-api/reference/v2.2/page/
For using with easyFB, you can do this:
ezfb.api( "/{page-id}", function (response) { if (response && !response.error) { /* handle the result */ } } );
What I did was to wrap a Rails app around my Angular app and then mounted a route to receive the signed_request
POST. That seemed the simplest way.
:smile: :+1: