Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home Facebook Graph API How To Ask People To Like Your Facebook Page On The Landing Page

How To Ask People To Like Your Facebook Page On The Landing Page

This tutorial will take you through How To increase fan for your Facebook page by asking them to like the page before accessing your great content. Meaning people have to become a fan in order to participate your contest, play your game/campaign.

I assume that you already added your App Profile Page as a Custom Tab (ex: Welcome) to your Facebook page. When people click on the Custom Tab link, it will determine to see whether current visitor is already a Fan to display a proper page.

Facebook  4RapidDev Landing Page

Facebook 4RapidDev Landing Page

On the image above, when click on Welcome custom tab on my Page, you will see a landing page with few Facebook Like buttons – on the top is the default Facebook Like button for Page and others are Facebook Like button plugin. When click on Like button, current visitor will become a fan and be redirected to the contest/game page. And you can change the copy as well as image to whatever you want, of course.

PHP script to check if people like Facebook page

In the PHP code below, I’m using the latest PHP Facebook Graph API therefore it may a little bit different with your current so let download my source code to check out the Graph API to ensure it works properly.

<?php
	require 'src/facebook.php';
 
	$facebook = new Facebook(array(
	  'appId'  => 'your-app-id',
	  'secret' => 'your-app-secret',
	));
 
	$signed_request = $facebook->getSignedRequest();
	$like_status = $signed_request["page"]["liked"];
 
	if(isset($_REQUEST["fp_pass"]) && $_REQUEST["fp_pass"] == "1"){
		$like_status = 1;
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
 
</head>
 
<body>
<?php if(!$like_status):?>
<div id="fb-root">
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
 FB.Canvas.setSize({ width: 520, height: 1000 });
window.fbAsyncInit = function(){
	FB.init({
		appId:'your-app-id',
		session:{},
		status:true,
		cookie:true,
		xfbml:true
	});
	FB.Event.subscribe('edge.create', 
		function(response){ 
			top.location.href = 'http://www.facebook.com/4.Rapid.Development?sk=app_246714398703948'; 
		}
	);
};
</script>
<div style="font-size:13px; color:#333333; line-height:24px;">
<p><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://www.facebook.com/4.Rapid.Development" show_faces="false" width="450" font=""></fb:like></p>
<a href="http://4rapiddev.com" target="_blank"><strong>4 Rapid Development</strong></a> is a technical blog that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers. We're talking about Web Development, Search Engine Optimization, Integrating with social media sites and other stuffs relate to tips/tricks and tutorials.<br /><br />
We try with my best to create useful articles with fully source code, step by step image illustrations as well as video tutorials in order for people be able to use and adapt rapidly and easily.<br /><br />
Simply click on the <fb:like href="http://www.facebook.com/4.Rapid.Development" layout="button_count" show_faces="false" width="70"></fb:like> button to enjoy all our great hard-working and meet all people like you.
</div>
</div>
<br /><br />
<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2F4-Rapid-Development%2F192737727433644&amp;width=480&amp;connections=40&amp;stream=false&amp;header=false&amp;height=500" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:480px; height:500px;" allowTransparency="true"></iframe> 
<?php else:?>
<h3>Thank you for loving my page!</h3>
<p>Place your content for your fan down here ...</p>
<?php endif;?>
</body>
</html>

<?php require 'src/facebook.php'; $facebook = new Facebook(array( 'appId' => 'your-app-id', 'secret' => 'your-app-secret', )); $signed_request = $facebook->getSignedRequest(); $like_status = $signed_request["page"]["liked"]; if(isset($_REQUEST["fp_pass"]) && $_REQUEST["fp_pass"] == "1"){ $like_status = 1; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if(!$like_status):?> <div id="fb-root"> <script src="http://connect.facebook.net/en_US/all.js"></script> <script type="text/javascript"> FB.Canvas.setSize({ width: 520, height: 1000 }); window.fbAsyncInit = function(){ FB.init({ appId:'your-app-id', session:{}, status:true, cookie:true, xfbml:true }); FB.Event.subscribe('edge.create', function(response){ top.location.href = 'http://www.facebook.com/4.Rapid.Development?sk=app_246714398703948'; } ); }; </script> <div style="font-size:13px; color:#333333; line-height:24px;"> <p><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://www.facebook.com/4.Rapid.Development" show_faces="false" width="450" font=""></fb:like></p> <a href="http://4rapiddev.com" target="_blank"><strong>4 Rapid Development</strong></a> is a technical blog that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers. We're talking about Web Development, Search Engine Optimization, Integrating with social media sites and other stuffs relate to tips/tricks and tutorials.<br /><br /> We try with my best to create useful articles with fully source code, step by step image illustrations as well as video tutorials in order for people be able to use and adapt rapidly and easily.<br /><br /> Simply click on the <fb:like href="http://www.facebook.com/4.Rapid.Development" layout="button_count" show_faces="false" width="70"></fb:like> button to enjoy all our great hard-working and meet all people like you. </div> </div> <br /><br /> <iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2F4-Rapid-Development%2F192737727433644&amp;width=480&amp;connections=40&amp;stream=false&amp;header=false&amp;height=500" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:480px; height:500px;" allowTransparency="true"></iframe> <?php else:?> <h3>Thank you for loving my page!</h3> <p>Place your content for your fan down here ...</p> <?php endif;?> </body> </html>

Note:

  • 1. Update the your-app-id and your-app-secret (on lines: 5,6,32) with yours. You can find them in the Application Settings Basic page as below:
    Facebook Find App ID and App Secret

    Facebook Find App ID and App Secret

  • 2. Again, you’re free to make your landing page more sexy and interest to engage people become your fan. 🙂
  • 3. In the scope of this tutorial, I don’t mention How to integrate with Facebook user information (ex: profile, friends, photos, etc). We will talk about it later, please wait.

+ Download my source code and current Facebook PHP SDK
+ View demonstration on my Facebook page

Sep 23, 2011Hoan Huynh
ASP.NET Web Request POST/GET HTTPS Ignore Certificate ValidationAuto Delete Old IIS Logs, FTP Logs, SMTP Logs In Windows
You Might Also Like:
  • Show Latest People Of Facebook Fan Page
  • PHP Get Likes Number Of Facebook Page
  • Get Or Find Facebook Fan Page Id Number
  • Facebook Like Button And Recommend Button With fb:like, iframe and html5
  • Make Short URL For Facebook Profile, Fan Page Or Application Page
  • Suggest Facebook Fan Page To All Friends
  • Facebook Publish To Wall With External Link And Track Callback
  • PHP Check If User Like Facebook Page
  • Facebook Removed View App Profile Page link For New Apps
  • Add Notes Applications To Facebook Fan Page
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

9 years ago Facebook Graph APIFacebook, Facebook Fan Page, fbAsyncInit, getSignedRequest381
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
21,918 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
19,746 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
15,584 views
JQuery Allow only numeric characters or only alphabet characters in textbox
13,094 views
C# Read Json From URL And Parse/Deserialize Json
9,557 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Research Paper Writing Service
  • Annotated Bibliography Example – How it Can Help You
  • Essay Writing Online Tips – How to Write Essays Online With Essay Proof Editing
  • Get Research Paper Assistance From Professional Help
  • Customized Essay Writing Agency – Why You Want It
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (28)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (62)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development