I have made a facebook App and associated with a page. I only want people that like the page to be able to use the app. Is this possible?
Asked
Active
Viewed 229 times
0
-
There is some PHP and JS sample code on http://stackoverflow.com/questions/4750012/facebook-check-if-user-liked-the-page – Aaron Brager Feb 12 '13 at 20:03
1 Answers
1
When somebody tries to load your app, they will need to be authorised.
Once authorised, you can query the user's graph to see what they like:
(I've assumed you've authorised using the php sdk, and will have the $facebook object, however the principle is the same for other techniques)
$fanPageId = "xxxxxxxxx";
$appId = "xxxxxxxxxx";
$fanPageLiked = false;
$appLiked = false;
$likes = $facebook->api('me/likes');
foreach ($likes['data'] as $ilike) {
if ($ilike['id'] == $fanPageId) {$fanPageLiked = true;}
if ($ilike['id'] == $appId) {$appLiked = true; }
}
if ($fanPageLiked)
{
.... run your game.
}
else
{
.... redirect to fan page.
}

Relaxing In Cyprus
- 1,976
- 19
- 25