Question

I have a Facebook fan page for a website. I want to run a loyalty contest where I will give virtual points to the users who like or comment on the posts on my page. At some point of time, these points will convert to actual money.

My Question is: Can I find a list of users who like a post/any post/many posts on my Facebook page or who commented on the posts? I have a Facebook app that collects FB IDs of users who are fans of my Facebook page, and to qualify for the contest, I will mandate that the users subscribe for this app. So once I find out such users, I will cross reference them against my user collection and allot points for every like or comment. I am the admin of my Facebook page and will have complete access. And I want to do this in programmatically.

Is it possible to do this using Open Graph queries or FQL or the insights API?

Finding out the post ids of my posts and then querying against the likes table was one approach I was considering. Is there a better approach than this?

I am coding this in .Net (ASP.Net and C#)

Appreciate any help that you can give me

Was it helpful?

Solution

This is much easier than you think. The key is getting the post_id from the stream object.

SELECT user_id 
FROM   like 
WHERE  post_id IN(
           SELECT post_id
           FROM   stream
           WHERE  source_id=YOUR PAGE ID)

What we are doing here is grabbing all of the posts on your page and then querying the like table for users that liked those posts.

The call for comments is almost identical except the column you are looking for is fromid instead of user_id

SELECT fromid 
FROM   comment 
WHERE  post_id IN(
           SELECT post_id
           FROM   stream
           WHERE  source_id=YOUR PAGE ID)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top