How to get all friends from a user that likes a give page?

Go To


How can i get all my friends that likes a given page without itearting over the list of friends and the list of likes for that friend?

The dumbway would be like:

friends_like_page = []
for f in friends:
   for l in
      if l = page_id:

But i'm wondering if there's a way to construct a FQL query for this.

Advance #2 and SOLVED:

Using the advice by @Igy i could solve it. I posted the answer below there. Anyway, i'm accepting Igy's answer becouse it was his idea that helped me.

Advance #1:

Ok, i've got this right now:

Fetch all friends:

SELECT uid2 FROM friend WHERE uid1 = me()

Fetch page fan from a user UID:

SELECT uid, page_id FROM page_fan where uid = UID


SELECT uid, page_id FROM page_fan WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me())

But, it doesn't seem to work properly. What's going on?

2012-04-04 19:59
by santiagobasulto


You can't get a list of who likes a page, you always need to start with the users and work back towards the page - the quickest way to do this is probably to retrieve the users' friends' likes in a batch query and compare the results with some array search operators

2012-04-05 15:32
by Igy
+1 Thanks Igy, i slved it with a batch query - santiagobasulto 2012-04-05 19:40


So, after fighting an entire day i finally solved it. As @Igy said, I constructed a batch request, here's it:

curl \
    -F 'access_token=...' \
    -F 'batch=[
             {"method": "GET",
                "name" : "get-friends",
                "relative_url": "me/friends",
              {"method": "GET",
                "relative_url": "likes/?ids={result=get-friends:$.data.*.id}"
2012-04-05 19:40
by santiagobasulto