armand
armand

Reputation: 9

facebook: how to show content in page only if user likes it

how can i show or display information only if the user is fan or likes my page? there are several pages that do that to catch more fans. thanks!

edit: like the victorias secret page with this box http://www.facebook.com/victoriassecret?v=app_117241824971601&ref=ts

Upvotes: 0

Views: 11823

Answers (7)

ruedamanuel
ruedamanuel

Reputation: 1930

If you're using the php sdk, you can use a call to the facebook object api and then determine if they have the like you want them to have.

$path = 'me/likes';
$likes = $facebook->api($path);

More info here

Upvotes: 1

Karl Adler
Karl Adler

Reputation: 16836

Google for Facewall Script, that should do what you want. But keep in mind to offer an option for users that not have Facebook Account.

Upvotes: 0

TouSt
TouSt

Reputation: 29

If you mean Facebook Page, use functions from Facebook API: Signed Request

$signed = parse_signed_request($_REQUEST['signed_request'], YOUR_APP_SECRET_KEY);

$signed = Array (
        [algorithm] => HMAC-SHA256
        [expires] => 13..
        [issued_at] => 13..
        [oauth_token] => ...
        [page] => Array (
                [id] => 29...
                [liked] => 1
                [admin] =>
        )
        [user] => Array ( [country] => cz [locale] => en_US [age] => Array ( [min] => 21 ) )
        [user_id] => ..
)

If current user like your Facebook tab page, you find out from $signed['page']['liked']

Upvotes: 1

John
John

Reputation: 474

My answer applies if you use an iFrame for your tab/canvas. First, you need to ask for permissions (just need basic info from user). Then, make a call to the Javascript API, like so:

FB.api('me/likes', function(response) {

});

This gives a JSON object of everything the user has liked. So, you have to loop through the response and try to find your page. If you are successful in finding it, display the awesome content!

Hope this helps!

Edit: Looking back, my answer was way off. This information is actually contained in the signed_request given by Facebook.

Upvotes: 3

NateHill
NateHill

Reputation: 355

There doesn't have to be any code involved. Just create a landing page (you could create a jpeg photo and link to the photo) and set that as the default landing page in your page settings. For users who are fans they go directly to the wall posts. All other people (non-fans) go to your specified landing page.

By the way, you realize that people can still access your content by just clicking on one of the tabs, correct? Even the Victoria Secrets example allows you to click on the "wall" tab, for example, and see the content.

A lot of people just like the page because it's the default landing page and they "think" they have to like the page first. It's more social psychology than anything else.

Upvotes: 0

Tim C
Tim C

Reputation: 1934

This is a privacy and security setting. Facebook Privacy FAQ

Upvotes: 0

Related Questions