Check If The User Likes (Fan Of) Your Facebook Page When Landing On Your Page Tab

Check when user landed on facebook fan page tab, Wheather he is fan of this page or not ?

A lot of developers and admins Facebook pages don’t know that they can detect whether the visiting user is already a fan of the page or not.

When the user visit your Page Tab, Facebook will send you the usual signed_request but with additional parameter called page.

When a user navigates to the Facebook Page, they will see your Page Tab
 added in the next available tab position. Broadly, a Page Tab is 
loaded in exactly the same way as a Canvas Page. When a user selects 
your Page Tab, you will received the signed_request parameter with 
one additional parameter, page. This parameter contains a JSON object 
with an id (the page id of the current page), admin  (if the user is a 
admin of the page), and liked (if the user has liked the page). 
As with a Canvas Page, you will not receive all the user information 
accessible to your app in the signed_request until the user authorizes 
your app.
<?php
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
if (empty($data["page"]["liked"])) {
    echo "You are not a fan!";
} else {
    echo "Welcome back fan!";
}
?>

Share and Enjoy

  • Facebook
  • Twitter
  • Google Plus
  • Live
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
  • Instapaper
  • FriendFeed

Comments

  1. Great write-up, I’m regular visitor of one’s site, maintain up the excellent operate, and It is going to be a regular visitor for a lengthy time.

  2. Hi, Neat post. There is an issue with your web site in internet explorer, could check this… IE still is the market leader and a large element of people will miss your excellent writing because of this problem.

  3. Somebody necessarily help to make critically articles I would state. This is the very first time I frequented your website page and thus far? I surprised with the research you made to create this particular submit amazing. Great activity!