facebook-authSome things with Facebook are easy while others are more challenging. Getting a list of Facebook friends has been, traditionally, one of the more challenging tasks: you need to use facebook.request() to ask for the "me/friends" object, convert the huge JSON object into a Lua table, and then load that into a newTableView() widget — including downloading each friend’s avatar and inserting it. Then you need to handle the potential selection of several friends and work the data back into your app where you can use it.

Fortunately, Corona SDK offers an easier way to select a set of Facebook friends using the facebook.showDialog() API.

Initial Setup

With any app that uses Facebook, you have to set it up so it will communicate with Facebook. This, in itself, is not a trivial process — see the Implementing Facebook Guide for details.

On iOS, you must include (at the minimum) the following in your build.settings plist section:

In addition, make sure that you build with a provisioning profile that matches the com.yoursite.yourapp entry which you added on the Facebook Developer Portal.

On Android, you must build your app with the Keystore and Alias of the keystore which you used to build the keyhash from the developer portal.

App Code

Next, you should set up the basic Facebook login processor. This includes a require of the Facebook library, a listener to handle the login process, and logging in to Facebook.

Now the Facebook system is initialized. As for the “Friends” dialog itself, it requires a callback listener which gathers the list of friends returned:

Next, set up a “show dialog” function and a basic button to trigger it:

In Summary

With this code in place, you can easily pick a list of friends to social network with. What you do from there is up to your imagination!

Excerpt from:

Tutorial: Getting Facebook Friends (the Easy Way)