Facebook API: All links shared by all friends? - facebook-graph-api

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.

Related

Access to other contacts groups information

From Google Contacts web interface you can edit a contact and include her in several groups/tags. Then if you decide to "Hide from contacts", the contact will not be in My contacts anymore, but she still exists in Other contacts, and also you can open her and see the groups.
However, People API don't let to know the groups of Other contacts, since you can only retrieve names , emailsAddresses and phoneNumbers.
Is there any workaround for this?
Ok, I figured out that Other contacts have the resourceName in the form otherContacts/<contact-id>, but if you change it to people/<contact-id> (keeping the same contact-id) you can retrieve all the other contact fields with People.People.get()

How do I compare two facebook UIDs to determine if they are friends?

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.

Facebook Profile Pictures for non-Friends

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.

Facebook API to search friend's properties

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.

FQL query for photos returns photos from hidden (blocked) users. How to prevent this?

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.