Send to Facebook friends with the "Registered" attribute

Basically what I would like to do is:

  • Get Facebook friends of current user
  • Give this collection, differentiating users who are already registered in my application, to other users, adding to each element of this collection the attribute 'registered' set to true or false

I managed to find the Facebook friends of the current user and assign them to my application.

Usercontroller

  def facebook_friends @friends = graph.get_connections("me", "friends") end 

RABL

 object false node :data do @friends end 

It returns something like:

 { data: [{ 'id': '23456789' 'name': 'Bobby Brown' }, { 'id': '23456788' 'name': 'Bobby Black' }] } 

but I would like something like this:

 { data: [{ 'id': '23456789' 'name': 'Bobby Brown', 'registered': true }, { 'id': '23456788' 'name': 'Bobby Black', 'registered': false }] } 

But I do not know how to make the second part without spending extra resources.

+4
source share
2 answers

There is a simple API Graph request for this.

 me/friends?fields=id,name,installed 

https://developers.facebook.com/tools/explorer/

It returns JSON. Users who have the application installed: true have installed: true

 @graph.get_connections('me','friends',:fields=>"id,name,installed") 
+5
source

I assume that you mean registered in your application

Instead, you can use FQL to build the answer you need as the user table has a registered field called is_app_user

SELECT uid, name, is_app_user FROM user where uid in (SELECT uid2 FROM friend WHERE uid1 = me())

Which should return something like

 { data: [{ 'id': '23456789' 'name': 'Bobby Brown', 'is_app_user': true }, { 'id': '23456788' 'name': 'Bobby Black', 'is_app_user': false }] } 

If you mean users that are checked by Facebook, I think that it works only with an authenticated user.

verified field

0
source

All Articles