Question

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 friends.like:
      if l = page_id:
        friends_like_page.append(f)

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

Combined:

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?

Was it helpful?

Solution

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

OTHER TIPS

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

curl https://graph.facebook.com \
    -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}"
              }
    ]'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top