I have a rails app that uses omniauth for Facebook login. I also use fb_graph to get the user's friends list. Instead of displaying ALL of the current_user's friends, I only want to display his friends who have used my app before.
The way I am thinking of doing this is adding a field to my user model that I can check in the view that I display the friends from. So for example
graph_user = FbGraph::User.me(current_user.oauth_token)
#friends = graph_user.friends
in the controller. Then in the view I can have:
#friends.each do |friend|
- if User.find_by_uid(friend.uid)
# display that friend
unfortunately, 'friend' doesn't have a uid but users who are authenticated obviously do. Is there something I can request from Facebook upon creating a new user, maybe email?, that I can check later against 'friend.'
Would checking email be ok? Currently we don't request email from Facebook login, but if I did, I don't think friend.email would allow me to collect that either, would it? What is a better way?
EDIT: I found this other SO post that says I can grab access tokens from friends or something, but I don't really understand, maybe someone could shed some light or point me to a tutorial?
Thanks
You can use fql directly to get the friends who use the app. I'm not sure how to use fql in ruby but this post might help you- Facebook FQL Query with Ruby
The query to get the friends who use the app-
SELECT uid FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
(user table)
Related
I'd like to get user_id of the user who login on mobile app by Facebook SDK.
Please tell me the following idea is good or not.
1) It is got facebook_id of user by FB SDK for iOS.
https://developers.facebook.com/docs/ios
2) On server-side, it is made User model and FBUser model, FBUser model is child of User model.
3) It is checked the facebook_id user exists or not on server-side.
4) If the user exists, api tells the user_id. If the one doesn't exist, the new User model is made, then api tells the user_id.
I'm worried that it is bothersome.Especially, to check whether the facebook_id user exists or not is troublesome.
I expect that to user Omni-auth login for rails is one option.
My purpose is following.
1.To login by FB
2.To set serial number for user who login by any method(email, Fb and other omni-login)
If you know better way, please advise me. Thx your kindness.
In fb-sdk 3.x. I was able to get request id after user has sent requests to their friends(usingFBWebDialogs) this way I could show in my app that user has invited friends which improved user experience because user got confirmation that invites were sent.
Now with fb-sdk 4.0(using FBSDKAppInviteDialog) I don't receive any data which would enable me to show invited friends.
Do you have any suggestions how to get list of invited friends?
There is no way to get list of invited friends.
The issue was discussed with Facebook engineer Emil Hesslow at Facebook Developer Community group. Here is relevant part of one of his comments:
And if they expect their friends to show up in the app it is just
because it was working like that before. Not because everyone always
assumes that will happen if you invite someone.
And no you can't get who they invited
I am developing a MVC project where I am trying to get the user id or user name from the facebook by using the email id provided by the user,
actually i want to fetch the photo of the user, which can be done using
graph.facebook.com/user_id|user_name/picture
where as i have only have the user email id.
with a little surfing on net i found that user name or user id can be fetched by using
graph.facebook.com/search?q=emailAddress&type=user&access_token=ACCESSTOKEN
but i was not able to get the access_token.
Also referred
developer facebook page
and also this
Any help or direction to work will help indeed.
Basically i understand that i need a access token to get the details.
So how do i do this in my MVC application
As you can read in the Search API docs, you can only search for Users by name, but not by E-Mail. It may have been possible in the past, but it is definitely not possible anymore.
Also, for searching by name, you need to use a User Access Token. You only get one by authorizing a User: https://developers.facebook.com/docs/facebook-login
I want to Scan Facebook friends list and find potential relationship between Facebook user and potential friend.After login I will give a user id then the system should find out the whether he is a friend any of my friend or friend's friend.Loop friend’s friend list up to 3 levels. If there are matches present data in hierarchical format.My application was in Asp.net mvc3. Can you please suggest me a solution .
You need user_relationships permission for your needs , Refer this documentation https://developers.facebook.com/docs/reference/login/user-friend-permissions/
As mentioned, for example, my name is Nicholas, I have 200 friends, and I'm able to get a list of my friends with no problem. Now I want to choose one of my friends and retrieve their friends list, I'm using
get_connection(friend_name , "friends")
my controller is
get_friend_friennd_list(friend_name)
and in my view
get_friend_friend_list_path(friend['name'])
however, it gives me an error, anyone know how to do it? Any hints?
You can't get friends of a friend on Facebook. If you try, Facebook will give you an error:
"(#604) Can't lookup all friends of XXXX. Can only lookup for the logged in user or the logged in user's friends that are users of your app.",