Posted By

the_construct on 02/11/12


Tagged

php fan-gate


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Net-Freak


Facebook Fan/Like Gate using PHP


 / Published in: PHP
 

Show and hide content based on whether or not a user has clicked the 'Like' button of an app.

  1. // THE 'facebook.php' FILE CAN BE FOUND ON Github (https://github.com/facebook/php-sdk)
  2. // YOU NEED A COPY OF ALL FILES IN THE 'src' FOLDER ON Github AS PART OF YOUR PROJECT
  3. // THEN YOU ONLY NEED TO INCLUDE ONE FILE INTO YOUR PHP CODE...AS PER BELOW
  4.  
  5. require 'incl/facebook.php';
  6.  
  7. $app_id = "YOUR APP ID";
  8. $app_secret = "YOUR APP SECRET";
  9. $facebook = new Facebook(array(
  10. 'appId' => $app_id,
  11. 'secret' => $app_secret,
  12. 'cookie' => true
  13. ));
  14.  
  15. $signed_request = $facebook->getSignedRequest();
  16. $like_status = $signed_request["page"]["liked"];
  17.  
  18. if($like_status){
  19. header('Location: home.php');
  20. }else{
  21. echo 'You Dont Like this';
  22. }

Report this snippet  

You need to login to post a comment.