Let's say two users are using an application and have granted the application appropriate permissions to retrieve their likes. Is it possible using FQL or the graph api to find what likes they have in common? Similar to how you can find mutualfriends between two users using the graph api. I don't think such an api call exists as I went through the docs but I may have missed it. I'd like to know if this is possible and if so, how it can be done. I really stink with SQL and just started with FQL and can get all the likes from a single user, but how do you get only the common likes between two users (if at all possible)?
Asked
Active
Viewed 2,265 times
2 Answers
3
This can be achieved via FQL.
1) Select the pages of user 1
SELECT page_id FROM page_fan WHERE uid = $user1
2) Select the pages of user 2, and use the page_id's from the previous query as another filter (aka - a sub query)
Which gives you a final complete query that accomplishes this:
SELECT page_id FROM page_fan WHERE uid= $user2 AND page_id IN (SELECT page_id FROM page_fan WHERE uid = $user1)

Tommy Crush
- 2,790
- 1
- 15
- 18
-
Awesome, thanks very much. The explanation was especially appreciated. – landland Feb 16 '13 at 23:31
-
Hi Tommy, after playing around with this some more it doesn't seem to work and is returning an empty data set. To test, I used two users, and did SELECT page_id FROM page_fan WHERE uid= $user1 and then SELECT page_id FROM page_fan WHERE uid= $user2. They both contain a common page_id as I double checked. However, when I combine the statement from your example using SELECT page_id FROM page_fan WHERE uid= $user2 AND page_id IN (SELECT page_id FROM page_fan WHERE uid = $user1) the data returned is empty. This is using the FQL Query tool from Facebook. Any ideas? – landland Mar 01 '13 at 17:41
-
Logically, the query works. So I don't know if there's an issue with timing on this, or what. Try doing this by running a multi query and see what you get: https://developers.facebook.com/docs/reference/rest/fql.multiquery/ – Tommy Crush Mar 01 '13 at 22:07
-
Subqueries (like the IN (SELECT)) may have a LIMIT parameter attached to them. Try explicitly setting LIMIT 500 on each query – Tommy Crush Mar 01 '13 at 22:09
-
Still nothing :( I've tried "query1": "SELECT page_id FROM page_fan WHERE uid= $user1 LIMIT 500" "query2": "SELECT #query1 FROM page_fan WHERE uid = $user 2 LIMIT 500" with and without the LIMIT clauses as well as SELECT page_id FROM page_fan WHERE uid= $user2 AND page_id IN (SELECT page_id FROM page_fan WHERE uid = $user1 LIMIT 500). – landland Mar 01 '13 at 23:04
-
1No, it would be: "query1": "SELECT page_id FROM page_fan WHERE uid= $user1 LIMIT 500" "query2": "SELECT page_id FROM page_fan WHERE uid = $user2 AND page_id IN (SELECT page_id FROM #query1) LIMIT 500" – Tommy Crush Mar 02 '13 at 02:12
-
Otherwise, try a few combinations of people. If its always empty, and you're sure that you have the permissions to read the data, then its time to file a bug with Facebook – Tommy Crush Mar 02 '13 at 02:13
-
Darn, still nothing. I'll file a bug. Thanks for the help! – landland Mar 02 '13 at 19:52
-
The query doesnt work because you need to provide access_token of both users at the same time and its not possible – Rana Deep Sep 26 '13 at 19:59
-
@RanaDeep, you are incorrect. You do not need the `access_token` of both users. All you need is one access token with both `user_likes` and `friends_likes` permissions enabled. https://developers.facebook.com/docs/reference/login/extended-profile-properties/ – Tommy Crush Sep 30 '13 at 01:56
-
i presumed you only have user_likes permission enabled since the questioner said 'their' likes meaning 'their own' ie user_likes likes – Rana Deep Sep 30 '13 at 02:03
0
FQL ain't available anymore. You can do it with the graph API from facebook. Something like this :
graph.setAccessToken(user.facebookToken);
graph.get("/"+targetFacebookId+"?fields=context", null, function(err, result) {
if (err) {
notDoStuff(err);
} else {
doStuff(result);
}
});

frammnm
- 537
- 1
- 5
- 17