Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Facebook API: Adding a “Likegate” to your Application

Facebook API: Adding a “Likegate” to your Application

2

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.

Facebook, Facebook Graph API, Fan Page, PHP

2 comments on “Facebook API: Adding a “Likegate” to your Application”

  1. Facebook API: Graph API v2.1 Now Available, ‘Likegates’ No Longer Allowed | Web Niraj says:
    August 12, 2014 at 2:12 PM

    […] 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 […]

    Reply
  2. Facebook API: Essential Facebook Page App Code Snippets | Web Niraj says:
    February 2, 2016 at 10:11 AM

    […] 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. […]

    Reply

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Firewall Flash Gadget Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy