Adding a “likegate” to your application is very easy, and only takes a few lines of code to achieve. If you’re not familiar with a “likegage”, it’s basically a page that users’ who haven’t liked your page see, usually asking them to Like the page before seeing the actual content. Users who have already liked your page see something different. The below assumes that your application has been installed on your Facebook page.
Using the Facebook PHP SDK, you can get the signed_request
to see information about the viewer of the application on your page.
If you print_r
the content of the signed_request
, you will see something similar to:
Notice that you can also find out if the viewer is an administrator of the page, allowing you to show a link to the admin area for your application.
The signed_request
is encrypted using your application secret so it cannot be forged. The page
array will return the ID of the current page, so you can also taylor your application to show different content on different pages. If the user
is connected to your application, the user
array will also include their ID and some basic information.
[…] will always return true regardless of whether or not the person has liked the page. It means my Likegate tutorial will no longer work, but developers will be able to get the status of liked pages using the […]
[…] If you want to lock down your application to user who’ve Liked your page, you can use the Facebook PHP SDK (or similar) to detect this. Luckily, I’ve already covered this functionality in a previous post. […]