Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I invite friends from facebook using fb_graph?

Basically I want to display a list of friends (with pictures and names) and invite them to my app I'm creating in rails with the fb_graph gem. The link shows the flow of how this would work, basically you would click an "Invite Friends" button and a list of friends would pop up with a button allowing you to invite the respective user.

http://www.quora.com/User-Acquisition/What-is-the-best-invite-a-friend-flow-for-mobile

Is there a way to do this with fb_graph?

like image 266
locoboy Avatar asked Dec 09 '22 21:12

locoboy


2 Answers

You bet. Assuming you have a working implementation of fb_graph, you can get a list of friends with the following command (from https://github.com/nov/fb_graph ):

FbGraph::User.me(fb_token).friends

You can use that to generate your UI for your friends list, then invite the selected friends, like so ( untested modification from the previous link, as well as https://developers.facebook.com/docs/reference/dialogs/requests/ ):

app_request = FbGraph::User.me(token).app_request!(
  :message => 'invitation message',
  :to      => friend.uid
)

The previous code also can accept a comma separated collection of UIDs.

I'll leave you to design and code the UI, but it is possible, using fb_graph, for sure. Those two links should be solid gold, should you decide to expand the scope, at all.

like image 171
Brad Werth Avatar answered Dec 28 '22 09:12

Brad Werth


Thanks for your interest for my gem.

Brad Werth's code works for existing (= already installed your app) users, but probably not for new users.

There are lots of limitations to send App Requests in background to avoid spamming. That limitation directly affect fb_graph's sending App Request feature.

If you are developing iOS app, I recommend you to use FB official iOS SDK. https://developers.facebook.com/docs/howtos/send-requests-using-ios-sdk/

Using iOS SDK (or JS SDK in html5 app), you have less limitations.

ps. I'm not familiar with Android App development nor FB official Android SDK, but I assume they have something similar functionality in their Android SDK too.

like image 44
nov matake Avatar answered Dec 28 '22 09:12

nov matake