Facebook - fan gate / re-direct issue
I have set up a business page on Facebook. Wh开发者_Go百科en user first arrives they see a custom welcome app iframe app that uses fan gating. (1) If user clicks LIKE then we forward them to the wall. (2) If user subsequently clicks on welcome app link they should be able to view the content as normal. Currently on the welcome app I have some javascript that forwards the user to wall:
<script type="text/javascript">
if (top != self) top.window.location = 'http://www.facebook.com/abc?sk=wall';
</script>
So the issue is I only need to forward the user to Wall if they've LIKED though not continue forwarding them to the WALL afterwards, though rather let them view the actual content.
How might this be done on Facebook? set a cookie?
From a parsed signed request (to an tab iFrame) you can get if the viewing user likes your page - the contents would be similar to the following (output of PHP print_r):
stdClass Object
(
[algorithm] => HMAC-SHA256
[issued_at] => xxxxxxxxxx
[page] => stdClass Object
(
[id] => FAN_PAGE_ID // target page id
[liked] => 1 // is the user a fan
[admin] => // is the user an admin
)
[user] => stdClass Object
(
[country] => ie
[locale] => en_GB
[age] => stdClass Object
(
[min] => 21
)
)
)
For more information see: http://developers.facebook.com/docs/authentication/signed_request/
If the user is a fan of your page the variable liked
with be set to 1. If not you can output your redirect:
<script type="text/javascript">top.window.location = 'http://www.facebook.com/abc?sk=wall';</script>
精彩评论