Posted By

reverend on 06/18/11


Tagged

authorize php page canvas app facebook


Versions (?)

php - Facebook Authorize App Script - Stack Overflow


 / Published in: PHP
 

URL: http://stackoverflow.com/questions/4812852/facebook-authorize-app-script

  1. <?php
  2.  
  3. $app_id = "[YOUR APP ID]";
  4.  
  5. $canvas_page = "[YOUR APP URL]";
  6.  
  7. $auth_url = "http://www.facebook.com/dialog/oauth?client_id="
  8. . $app_id . "&redirect_uri=" . urlencode($canvas_page);
  9.  
  10. $signed_request = $_REQUEST["signed_request"];
  11.  
  12. list($encoded_sig, $payload) = explode('.', $signed_request, 2);
  13.  
  14. $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
  15.  
  16. if (empty($data["user_id"])) {
  17. echo("<script> top.location.href='" . $auth_url . "'</script>");
  18. } else {
  19. echo ("Welcome User: " . $data["user_id"]);
  20. }
  21. ?>

Report this snippet  

You need to login to post a comment.