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!";
}
?>
Advertisements

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

  1. 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.

  2. 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!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s