php - Facebook Authorize App Script - Stack Overflow


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.