Show text when user likes a FB page - facebook

We're trying to do some things on Facebook but to be honest we have no idea where to start.
We have a Facebook application which doesn't require any authorization. It's basically just a static page showing some of our information at the moment. We added it to a page as a tab.
We want to show some welcome text when a user likes our page. How should we go about this? I haven't used the Facebook SDK before so I'm completely lost.
Can we do this through the JS SDK? Check if a user has already liked our page and show a welcome message, otherwise show the like button? We're working with Heroku FB apps, not sure if that's important.
I'm not looking for complete example code, just some pointers would be nice.
Thanks in advance.

What you're looking for is a fan gate.
Here's a decent explanation:
http://www.hyperarts.com/blog/customizing-facebook-iframe-application-signed_request_reveal_tab/
$signed_request = $facebook->getSignedRequest();
$like_status = $signed_request["page"]["liked"];
if ($like_status) {
echo "You like us";
}
else {
echo "You don't like us yet";
}

Related

how to get like status of facebook php sdk

I am making event page on facebook by using facebook php sdk.
i added fb app to fb page.
the page was made for fb event.
i tried some ways. but all failed.
Now, i will make two pages.
one is after clicking like.
the other is before clicking like.
i use this soruce to get userf id.
$user = $facebook->getUser();
it is to get user id source.
i want to know to get like status.
how can i get like status about facebook php sdk.
please let me know it. ^^ plz
If it is a page tab app the signed request will contained a liked parameter. You can read about it on https://developers.facebook.com/docs/appsonfacebook/pagetabs

Forcing Visitors to Liking Facebook Page

I have a Facebook page.
We will start a giveaway. And we will give gifts to our Facebook Fans . They will give a promo code if like our page. BUt we want to sure, they are really fan of our fan page.
Because of this, I want to create a new tab which say "You have to like this page for get promotion code" to user . When visitor like our page, he / she can see content tab. If not, they can't see.
It was easy on static FBML, but know how can i do it with iFrame ? My tab is ready. Created a new app and then this app added to page.
you need to parse the signed_request parameter, it has a Boolean attribute called liked.
you may want to look at this question

Facebook Check if user "Liked" the page

I made a few Facebook FBML Canvas pages (Facebook considers these to be Applications) for a company, and they requested that users who "Like" the page would be redirected to another page, or the page will display different content with AJAX.
I went through the Facebook Developers Documentation, but I can't find a clue on how to do it.
I'm sure someone has done it before, any suggestions?
I found this on the Facebook forum I think it might help you out!
How can i redirect when someone like/share?
I haven't tried it myself though!
Good luck!
You can use either the JS or PHP sdk to check if a user liked a page. See examples below...
Uses JS sdk to check if a user liked a page (can be any page, just set the page id). This can be used in a standalone app or from within a page tab. - http://unbound-media.com/facebook/how-to-tell-if-a-facebook-user-likes-your-facebook-application/
Uses PHP sdk to check if a user liked the page from a tabbed app (can only check if user liked the current page they're on). This method can also be converted to JS. - How to check if a user likes my Facebook Page or URL using Facebook's API
If you are dealing with facebook app tab page, the following code helps you to find isfan status
$signed = parse_signed_request($_REQUEST['signed_request'], 'YOUR-APP-SECRET');
if ($signed['page']['liked'] == 1) {
$fan = true;
} else {
$fan = false;
}
Visit this link for demo and source code.

adding facebook application as tabs

I have developed an Facebook canvas page and i want to use that application as a tag on a fan page owned by me. That can be done easily.
My doubt is that how do i make it sure that only i am able to add my application as a tab and not anyone else. I mean the method by which i would add the application as a tab on my profile page anyone can do it.But i only want that page to be visible on my Facebook fan page.
A bit late for you, but may be for others, I found out how to add my app to a new tab:
You need to create a profile for the page admin! If you didn't, on the top right of Facebook page you should have a link 'Create Your Profile'. It doesn't make sense to me but ...
Go to this link (thanks ifaour):https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=manage_pages&response_type=token
Got to your http://www.facebook.com/apps/application.php?id=YOUR_APP_ID and add the app to your page
For the private thing, you can check the page id:
$signed_request = $_REQUEST['signed_request'];
$secret = 'YOUR_SECRET_KEY';
$getdata = parse_signed_request($signed_request, $secret);
$fanpage_id = $getdata['user_id'];
if($fanpage_id != YOUR_PAGE_ID) exit('Sorry guys, that's just for me ...');

How to tell if a user is a fan of the fan page

I'm working on a FBML fan page for a client. I need to perform a check to see if the current user is a fan of the page. I tried using the JavaScript API but I've found this is not compatible with FBML.
I have looked through the FBML page on the developer wiki and found checks for practically everything else but no is user fan check.
Any pointers in the right direction would be most appreciated.
Thanks in advance.
Try this instead:
https://developers.facebook.com/docs/reference/fbml/visible-to-connection/
Please don't make those "Become a fan 1st" pages with it though. They're basically spam.
Try this page:
https://developers.facebook.com/docs/reference/rest/pages.isFan/
This is a good article - for doing this task in fan page tabs (most easily done with the static FBML app).
http://thinkdiff.net/facebook/how-to-detect-fan-of-a-facebook-page/
Be sure to read the fine print - such as if you’re admin of facebook page, you all time see the fan restricted item and non fan restricted item.
The best solution is to parse signed_request. This method does not need app authorization by user.
$signed = parse_signed_request($_REQUEST['signed_request'], 'YOUR-APP-SECRET');
if ($signed['page']['liked'] == 1) {
$fan = true;
} else {
$fan = false;
}
Here is a guide to Check User is Fan of Facebook.