Return to Snippet

Revision: 47926
at June 18, 2011 07:57 by reverend


Initial Code
<?php 

     $app_id = "[YOUR APP ID]";

     $canvas_page = "[YOUR APP URL]";

     $auth_url = "http://www.facebook.com/dialog/oauth?client_id=" 
            . $app_id . "&redirect_uri=" . urlencode($canvas_page);

     $signed_request = $_REQUEST["signed_request"];

     list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

     $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

     if (empty($data["user_id"])) {
            echo("<script> top.location.href='" . $auth_url . "'</script>");
     } else {
            echo ("Welcome User: " . $data["user_id"]);
     } 
 ?>

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

Initial Description

                                

Initial Title
php - Facebook Authorize App Script - Stack Overflow

Initial Tags
php, page, facebook

Initial Language
PHP