It's possible to access friend names in the Graph API. However, I want a method - either via the graph or App API to be able to search based on specific properties.
Eg: searching for all friends from London, UK.
Or searching all friends who enjoy photography.
Any places or API that may be able to assist with this?
You can search several of the properties querying the user table with FQL. For example, here is a query for all female frinds:
select uid, name, sex
from user
where uid in (SELECT uid2 FROM friend WHERE uid1 = me())
and sex="female"
The location is a complex object and I am not sure if it can be queried on like the other fields.
Related
i have authenticated users using devise and omniauth facebook gem in my rails 3.2 app. How can i determine if two users are friends based on their uid only? Is it better to use Facebook query language or some other means? please provide an example
You can do this using the Graph API by checking /me/friends/USER_ID_TO_TEST or FQL with SELECT uid1, uid2 FROM friend WHERE uid1 = me() and UID2 = USER_ID_TO_TEST
One of the two users has to be authenticated at the time or the query will fail.
The problem with this is that if the users are not friends, Facebook will return an empty data set. If you don't like that, then you need to retrieve a user's list of friends into your script and search the response for the friend to test.
I am creating an iPhone email client that displays sender's profile pictures in in the UITableViewCells in the inbox, much like Sparrow does. I am using the following FQL query to grab these images:
SELECT
pic_big
FROM
user
WHERE
uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
AND
strpos(lower(name),'INSERT_FIRST_THREE_LETTERS_OF_FIRST_NAME_HERE') >= 0
AND
strpos(lower(name),'INSERT_LAST_NAME_HERE') >= 0
ORDER BY name
I get the names of the senders from the email headers, and then search the user's Facebook friends using the full last name and the first three letters of the first name to account for nicknames. This works pretty well on the whole.
Sparrow, however, is able to grab profile pictures from Facebook for users I am not even friends with. How is this possible? I though queries were limited to specific groups, like your friends. And that searches for email addresses were not valid? Is this correct? How does Sparrow grab these profile pics?
Well as long as you know the users Facebook ID - it's a long number but treat it as a string. You can use this url to get their profile picture:
https://graph.facebook.com/[id]/picture
No need for anything more complex.
You can get the user_id of any known user from their email by making an API call to:
/search?type=user&q=USER#EMAIL.NET
If their email is registered with Facebook and public, you'll get back a JSON object with their name and user id. You'll need to make a separate call (or use a batch request) to get their picture from their ID.
It doesn't look like the input that FB uses for current city and hometown is available as a widget or dialog for developers to use. I'd like to create an autocomplete input field that uses the same names for cities and the corresponding ID's. There's the lists of the cities that FB publishes for post and ad targeting but that is incomplete and appears to be using a different ID space; I'd like the same cities and IDs that are available to users when they edit their current city on their profile. Using jquery to do the autocomplete part is doable but I just can't find an API or data source available to populate it.
Does anybody know how to access that data from the graph API, fql or any other Facebook sanctioned means?
I havn't seen a graph api or fql method for this. The best I have seen from Facebook is this list: https://www.facebook.com/ads/api/autocomplete_data.php which you would want to parse and cache the json since its a pretty big download. If you needed more details about the location, you could call the graph api by the id provided in that file.
What is the most practical way to access the links shared by the whole of a users' facebook friends?
I'm looking to scrape all the links to a handful of domains, shared by the friends of the authenticated user.
Is there a way to ask for "All links of domain X", "All links" (and I'll filter for domain X) or do I need to fetch each friend and parse each individual feed? I'm assuming there's a main "Inbound" feed that will be all the links from all the friends. True? Not true?
select title, url, owner from link where owner in (select uid2 from friend where uid1 = me() limit 100)
will return links shared by friends of the authenticated user. You would then need to filter the urls for the domains you are interested in. Since the URL field in the Link table is not indexed, you cannot perform a WHERE on it in the FQL.
For domain searching try adding something like WHERE strpos(url,'domain.com') > 0, asside to an indexable column in your where clause.
I request latest photos for a user using an FQL query, like the one below:
SELECT pid, aid, owner, src_small, src_big, src, link, caption, created FROM photo WHERE aid IN (SELECT aid FROM album WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=) ORDER BY modified_major DESC LIMIT 300) ORDER BY created DESC LIMIT 500
It works well but I believe it doesn't respect the setting where the user block specific users on the facebook page. So in my app, he sees all the photos, and he's not happy :).
Now, I see that in user table there's is_blocked property, but it's not indexed so I can't use it in a WHERE clause. I also don't want to call FB for every user I get just to check for that property and filter based on that in the app itself.
So, first of all, am I correct that this query doesn't respect blocked users settings?
If yes, is there a way to respect this setting using FQL?
You may look at privacy table. There is id column which represent an image object as well and deny field with a list of users that cannot see the object. I think you should use a fql.multi-query to resolve this. Some info about fql.multi-query you can find at this topic.