How can you query other user profiles using the Facebook Graph API? - facebook

I'm experimenting with getting user data from the Facebook Graph API, but so far I can only retrieve information from my own profile. Using the Graph API Explorer, I'm sending GET requests for this information:
me?fields=id,name,birthday,picture,email
How can I change this to search for other users instead of "me"? For example, I want to search for profiles of people named "John Smith" and return pictures and birthdays for each profile of this name.

You can use the Search API to search for users by name: https://developers.facebook.com/docs/graph-api/using-graph-api#search
...but there is no way to get birthdays and emails of users if they did not authorize your App. You would not be allowed to use the emails anyway, even if you would get them.

Related

How to get my own Facebook user timeline using Graph API?

I would like to get all the posts and updates that are normally displayed in FB official application for MY account (this includes updates from my friends and liked pages).
I wasn't able to find any details how to get that, the only thing I've managed to get is my own posts.
Anyone got any experience with that using current Graph API verion (3.3)?
All the alternate FB clients (ex. Friendly) must be doing this somehow.
There is no way to get ANY data of users who did not authorized your App. Which means, there is no way to get posts of friends. You can only get your own friends, with the user_posts permission and the /me/posts endpoint. If some Apps access friend data without their authorization, they are most likely doing something that is not allowed.
Here is what I found in their API docs:
There are two scopes:
The user feed requires the user's permission
The public feed has fewer capabilities but doesn't require perms

How can I obtain a list of domains for a page/user/app using the Graph API?

I'm trying to use Facebook's Graph API to grab a user's insights data, and display it in an admin panel for them, as a part of their custom CMS.
There are a few steps to my Facebook integration:
1. Authenticate
2. Get a list of pages, applications, and domains for the user
3. Get insights data for each page, application and domain
All of the above are working, but I can't find a way to list all the domains a user has. I'm using https://graph.facebook.com/me/accounts to get the list of accounts for the user. This is returning all the Pages and Applications, but no Domains.
I have looked all over Facebook's docs, and can't find any reference to a method for retrieving a list.
I have tried https://graph.facebook.com/domains, https://graph.facebook.com/me/domains, https://graph.facebook.com/domain, and https://graph.facebook.com/me/domain - to no avail. https://graph.facebook.com/domain and https://graph.facebook.com/domains are valid, but are only useful if you know the domain.
So, the question: Is there a way to obtain a list of domains for a user using the Graph API?
Thanks
try this Graph API call: https://graph.facebook.com/fql?q=SELECT domain_name, domain_id FROM domain WHERE domain_id in ( SELECT domain_id FROM domain_admin WHERE owner_id=me())&access_token=VALIDUSERACCESSTOKENOFTHEOWNEROFTHEDOMAIN

Retrieve total number of friends a registered user to a facebook app

i have a facebook app, in wich the administrator of the app needs a report of the users registered to this app and one of the data i need is to get how many friends does a user registered to my app has, i was trying with fql using a query like this
$facebook->api_client->fql_query("select uid2 from friend where uid1=$userId");
but is not working, is there any other way to achieve this?
I remember the facebook API Documentation to be rather sparse with this sort of thing, but maybe you want to look into the facebook Graph API. From there, you can get registered users of your application.
Facebook 'Friends.getAppUsers' using Graph API
http://developers.facebook.com/docs/api
==EDIT==
Facebook Graph API pattern:
https://graph.facebook.com/ID/CONNECTION_TYPE
If you want all the friend data from any user, you can use
https://graph.facebook.com/USER_ID/friends

"Find Friends" using Twitter Oauth or Facebook Connect connections

Using Twitter OAuth, I'm saving the user's data as JSON in a "twitter" field in my database. Likewise, I'm saving the user's Facebook Connect info (including persistent session_key) as JSON in a "facebook" field.
For most operations, this is great. However, I'd like to add a "Find Friends" function that will grab the user's friends from either service, compare against users on my service, and show the resulting list to suggest friends.
The initial problem: doing a DB call to compare the user's friend list against usernames that are in JSON.
First idea: if I can get a list of all users that have authenticated my application (along with their emails), I could then find users in my database with those emails. However, I'm not aware of any API call for either Twitter or Facebook that does that.
Any other idea on how to create this function?
Thanks in advance.
You could create tables for the users having their service ID in a field. (facebook or twitter user id).
Then just do a SQL search on the tables to find them. JSON isn't a good idea to store in a table for searching with.
Joe

Get a list of friends of a friend on Facebook

I've recently started looking into the Facebook API and am trying to work out how to retrieve the list of friends of another user (in this case the user is someone I'm friends with).
So far I've only worked out how to find out the friends of a person who I am also friends with. However the Friends Wheel application can do it as you can generate a wheel base on one of your friends, so I'm guessing it is possible.
Anyone know how to do this?
You Can only access friends list of logged in user(i.e, your friend list) or the logged in user's friends that are users of your app. i.e, You can access friends friend list only if your friends are the users of your app.
You can check if two of your friends are friends using friends.are_friends.
Once you've got a valid access token for a user, you can query the Graph API with said token and query the "friends" connection of the user object (/me/friends). So if your user ID is "123":
https://graph.facebook.com/123/friends?access_token=USERS_ACCESS_TOKEN
You can also use /me to reference the current user:
https://graph.facebook.com/me/friends?access_token=USERS_ACCESS_TOKEN
Without a valid access token, you cannot query information about users and access to friends of friends is determined by each user. For example, I cannot see some of my friend's friends:
Can't lookup all friends of (ID). Can only lookup for the logged in
user (ID), or friends of the logged in user with the appropriate
permission.
...but for some of my other friends, I can. There's probably a permission or flag you can check to see if they allow access, but I'm not currently seeing it.
I figured this out.
1) The best you can do is find mutual friends
2) Try using the v1.0 of the Facebook Graph API. v2.0 doesn't have /mutualfriends.
3) Since I was only interested in my own social network, I grabbed the access token from the graph explorer and wrote a python script to download my whole social network. The code is on github
Yes, its possible to get List of Friends of a friend but only condition is that friend should be user of that application.
Suppose there is an application "APP" used by "A" then the APP can get his friends List , now you want friends List of "B" who is friend of "A" , it will be possible only if "B" also uses the "APP"
Facebook are in the process of deprecating the REST API, and have added equivalent support to the Graph API for this method. You can use Graph API - User object and Get /User_id1/friends/User_id2 to check if User_id1 is friends with User_id2 .