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)?
How to get mutual facebook likes between users who are using an app
Asked Answered
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)
Awesome, thanks very much. The explanation was especially appreciated. –
Monas
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? –
Monas
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: developers.facebook.com/docs/reference/rest/fql.multiquery –
Curule
Subqueries (like the IN (SELECT)) may have a LIMIT parameter attached to them. Try explicitly setting LIMIT 500 on each query –
Curule
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). –
Monas
No, 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" –
Curule
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 –
Curule
Darn, still nothing. I'll file a bug. Thanks for the help! –
Monas
The query doesnt work because you need to provide access_token of both users at the same time and its not possible –
Boylston
@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. developers.facebook.com/docs/reference/login/… –
Curule i presumed you only have user_likes permission enabled since the questioner said 'their' likes meaning 'their own' ie user_likes likes –
Boylston
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);
}
});
© 2022 - 2024 — McMap. All rights reserved.