How to get relation between two facebook userid's - asp.net-mvc

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/

Related

how to get facebook user id or user name with email id

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

Cross check if Facebook friend has signed into your app before

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)

Facebook authentication without requesting friend list

I'd like to use Facebook OAuth authentication for a web application in a business context. What I need is a user ID and nothing else but Facebook by default always says "... will receive the following info: your friend list and email address".
Is there any way to configure Facebook or my application not to request the friend list for which I have no need to know?
By the way, I am using ASP.NET MVC but should be able to make the required adjustments to my application if someone can point me into the right direction.
If you are using Microsoft.Asp.net.Facebook like below tutorial
http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-facebook-birthday-app
You can set the attributes like below to get permissions for required things:
[FacebookAuthorize("email", "user_photos", "user_friends")]
if you don't need friends details remove the attribute.
[FacebookAuthorize("email", "user_photos")]

facebook fql query to gather all posts made from app with specific "id"

I need your help.
I have ios app with facebook
This app has many different objects which user can post to his facebook wall.
My problem is - when users post something about this object on their wall, i need mark this posts with "id" of this objects. Every posts about this object must be marked with this "id" (hash, etc) and after that i need create (fql query or graph API ) to gather all posts from every users walls which post about this object .
1) How to mark user's post with "id" ?
2) how (fql query or graph API) must be that it can gather specific posts from different facebook users walls
Please help me
As of now, this isn't possible. But since fB recently launched hash tags, you can wait for the hashtags API.
You could workaround with Search API, but this doesn't shows the exact matches!

Read Public Timeline from Facebook

I am new on iOS Facebook sdk. I am using version version 3.1.1. I can reach my profile's information via sdk. But I am wondering How can I access and read from other user's public timeline? I search on web but I couldn't find anything. Thanks for answers
All roads lead to Rome.
You can find other users' IDs by many ways on quite any API objects (likes and comments from photos and posts of friends or pages).
Example of a request that gets many users, from a Facebook page post:
https://graph.facebook.com/20531316728_107148006126775?fields=likes.fields(id)
At Facebook, you have a USER_ID and an alias. You can get the alias by accessing their public profile.
For example- https://www.facebook.com/shireesh.asthana which gives you the alias shireesh.asthana
Now you can get the actual User_Id by going to:
https://graph.facebook.com/shireesh.asthana
which gives you my User_id as 631951716
Now you can just do a GET request on 631951716/feed which will help you get the posts of that user(which of course you can see as a non friend).
Hope that helps!

Resources