Although there are less than 100 lines of code (including comments), this is a complete Facebook application implemented in +Perl , using the +Mojolicious web framework. It provides Facebook authentication and accesses user's Facebook username. Of course, with proper scope settings it could also access user's list of friends, the pages that the user manages, or many other interesting things that Facebook offers access to.
So, the complete app:
In order to make it work, you have to first create a Facebook application and then fill in the values for $config->{facebook}->{app_id} and $config->{facebook}->{secret} with the values provided by Facebook on the application Settings page:
After you have installed the dependencies:
You can start your app in dev mode by executing: morbo facebook
When you click on the Click here to authenticate with FB link, you (and your users) will be redirected to Facebook and presented with a screen like this
After you authorize the app to access all the scopes set on line 39, Facebook will redirect you back to your app. Note that this authorization phase is done just once - after that, every time you log in with that account, Facebook will simply redirect you to the app.
If you read this far and liked the article, get rid of your shyness and share it using the buttons on the left :)
0 comments:
Post a Comment