blackhatx2

Facebook Like Iframe Tutorial

Aug 20th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. https://blackhatx.com/seo-forum/
  2.  
  3. As most of you know FBML is being deprecated, so this code no longer works.
  4.  
  5. Code:
  6.  
  7. Non-fan content (eg. Like this page to see a monkey fly
  8. <fb:visible-to-connection>
  9. Fan content (eg. a flying monkey)
  10. </fb:visible-to-connection>
  11.  
  12. Here’s what’s needed:
  13.  
  14. A place to host files
  15. A FB PVA so you can create applications
  16. Time and willingness to read/follow these steps.
  17. Step 1
  18. Create a new application by going to:
  19.  
  20. Code:
  21.  
  22. http://www.facebook.com/developers/
  23.  
  24. Click Set Up New App
  25.  
  26. Enter a name for the application
  27. Click Agree to the TOS
  28. Click Create Application
  29.  
  30. Enter the Captcha
  31.  
  32. You will be leaded to you application setup page
  33. Click the Facebook Intergration tab
  34. Give a Canvas Page name (custom URL for your app)
  35.  
  36. Give a You are going to need to make a folder on your site for your
  37. Canvas URL (eg. http://www.test.com/iframe/ ) and then put that in as your Canvas URL
  38.  
  39. Change the iframe size to Auto-Resize (i just do that, up to you though)
  40.  
  41. Go down to the Page Tabs area:
  42. Insert a Tab Name (eg. Welcome!)
  43. For your Tab URL put the exact same link as you did for the Canvas URL
  44.  
  45. Save it so far.
  46.  
  47. Step 2
  48.  
  49. The code and setup
  50.  
  51. First step is to create a folder (eg. I called mine iframe)
  52. Inside that folder create a php file, we’ll call it index.php
  53.  
  54. Copy/Paste this code into index.php
  55.  
  56. Code:
  57.  
  58. <?php
  59.  
  60. include_once('fb_init.php');
  61.  
  62. // create the Facebook Graph SDK object
  63. require_once('facebook.php');
  64. $facebook = new Facebook(array(
  65. 'appId'=>'ENTER YOU APP ID HERE', // replace with your value
  66. 'secret'=>'ENTER YOUR APP SECRET HERE' // replace with your value
  67. ));
  68. $signedRequest = $facebook->getSignedRequest();
  69.  
  70. // Inspect the signed request
  71. if($signedRequest['page']['liked'] == 1){
  72.  
  73. // Show the content for the person who liked the page
  74. print '<script type="text/javascript">
  75. <!--
  76. window.location = "http://www.test.com/iframe/next.html"
  77. //-->
  78. </script>';
  79.  
  80. } else {
  81.  
  82. // Show the reveal ask content
  83. print '<script type="text/javascript">
  84. <!--
  85. window.location = "http://www.test.com/iframe/landing.html"
  86. //-->
  87. </script>';
  88.  
  89. }
  90. ?>
  91.  
  92. NOTES:
  93.  
  94. Please enter your App ID and App Secret into this code where stated.
  95. Please change the http://www.test.com/iframe/next.html to your website and create a html , call it next.html
  96. Please change the http://www.test.com/iframe/landing.html to your website and create a html , call it landing.html
  97. Next step is you will have to download and install the PHP SDK
  98.  
  99. Click here to download it
  100.  
  101. Extract all the files:
  102.  
  103. What we want from this is EVERYTHING in the src folder
  104. Put the files from the src folder into your iframe folder online
  105.  
  106. That means:
  107. base_facebook.php
  108. fb_ca_chain_bundle.crt
  109. facebook.php
  110.  
  111. all in /iframe
  112.  
  113. (DON’T do this /iframe/src please, it won’t work)
  114. Inside the folder iframe create a php file, called fb_init.php
  115.  
  116. Copy/Paste this code into fb_init.php
  117.  
  118. Code:
  119.  
  120. <?php
  121. // depending on your hosting provider, you may need to include
  122. // the entire path to the directory you added this file to, for example
  123. // if your FTP login is, 'monkey', it may be, consult your ISP's docs
  124. // for additional assistance:
  125. // require_once('/home/monkey/public_html/iframe/facebook.php');
  126. require_once('facebook.php');
  127. $facebook = new Facebook(array(
  128. 'appId'=>'', // from Facebook
  129. 'secret'=>'', // from Facebook
  130. 'cookie'=>true
  131. ));
  132. ?>
  133.  
  134. Change
  135. /home/ads/public_html/iframe/facebook.php
  136. to your directory.
  137.  
  138. Mine was shorter like
  139. ads/public_html/iframe/facebook.php
  140.  
  141. After that’s done. You’ve setup the code!!!
  142. Step 3
  143.  
  144. Setup landing.html and next.html with the things you want to show!
  145.  
  146. landing.html is the content for the person who has NOT liked the page yet
  147.  
  148. next.html is the content for the person who liked the page
  149.  
  150. for more information please visit..
  151.  
  152. https://blackhatx.com/seo-forum/
Advertisement
Add Comment
Please, Sign In to add comment