I created a sinatra based facebook app on Heroku by initiating it with the feature provided by Facebook (Get Cloud App or something like that). Everything worked fine, but when I tried to use the Scores from Facebook, I realized that the Facebook API used by Heroku (which is Mogli) does not support Scores.
So I tried to rewrite the code to use fb_graph. But since that created more confusion than everything I started with an empty file. But I just can’t make it work.
So basically I would like a simple example for a Sinatra based app on heroku which uses fb_graph. The samples should only contain authentication, since everything else seems pretty straight forward and has a lot of documentation. Just the initial authentication just doesn’t work.
I would like to use the default oauth2 approach with the callback, since it just feels more natural to me, but I’m open for everything. I know there is a Rails example, but I just can’t get my head around it and since my app will be very simple Rails seems a bit overpowered.
It would be great if anyone could give me just the few lines necessary for what I would like to do!
I’ve found this to be a bit of a mess. Old tutorials and code just don’t make sense anymore.
You can use the Heroku + Facebook OmniAuth example to do an external website (not a canvas app) that does server-side Facebook (and many others) authentication.
When you do that, OmniAuth will provide you with the token you need you need to pass to fb_graph. In the provided example you could add another url:
For canvas apps, I added the following code to ‘rack-facebook-request.rb’ to my repo based on this gist
This will give you the current fb_user_id and fb_access_token if your app is authorised. Remember that you have to use javascript or a link in the iFrame to request app authorisation in this case.