Inviting a friend to your app using Facebook API

216 views Asked by At

I have a web app built with a Rails backend and I want users to be able to Invite their friends to use the web app.

I've been using the Koala gem to interact with Graph API.

This is what my code looks like:

@graph = Koala::Facebook::API.new(fb_token)
@graph.get_connections("me", "friends") #returns an empty array
@graph.get_connections("me", "taggable_friends") #returns an array of friend hashes

Here is an example of 1 of the hashes:

{"id"=>"AaIpicqKReRNdvdbB1e8W1zAoNNZhiI6Yu5n-N8Dchlb1Ua88UDFFEXf1ENHTzJAxan9Bnlv3S0ci2DA6itDceRQbmYVhKYeVLoVd8IbXkV8FA",
  "name"=>"John Smith",
  "picture"=>
   {"data"=>
     {"is_silhouette"=>false,
      "url"=>"https://url-for-profile-photo"}}}

Then when I attempt to do:

@graph.put_connections("AaIpicqKReRNdvdbB1e8W1zAoNNZhiI6Yu5n-N8Dchlb1Ua88UDFFEXf1ENHTzJAxan9Bnlv3S0ci2DA6itDceRQbmYVhKYeVLoVd8IbXkV8FA", "notifications", template: "foo", href: "bar")

It returns this:

Koala::Facebook::ClientError: type: OAuthException, code: 803, message: (#803) Some of the aliases you requested do not exist: AaIpicqKReRNdvdbB1e8W1zAoNNZhiI6Yu5n-N8Dchlb1Ua88UDFFEXf1ENHTzJAxan9Bnlv3S0ci2DA6itDceRQbmYVhKYeVLoVd8IbXkV8FA, x-fb-trace-id: AQ9bWXVr2TL [HTTP 404]

Is there any way to send facebook notifications to get a user to join the application?

I am assuming I need to send the put_connections using a uid but facebook does not seem to be returning a uid back to me for users not registered with the application.

I see games like Candy Crush, etc, use this same method of inviting people to the game.

Any help would be greatly appreciated!

Thanks!

1

There are 1 answers

0
sump On BEST ANSWER

After some investigation and responses from WizKid it seems that this is not possible unless you have an iOS/Android application or a Canvas game.

I'm posting this answer so in future - if any other people have the same question it is much easier to see the answer rather than trying to dig through FB docs!

I will update if anything changes but as of the time posting this, it is not possible.