Created
May 18, 2015 15:55
-
-
Save CEscorcio/8a3ea6a34a3d0b93978a to your computer and use it in GitHub Desktop.
Facebook app Login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"]); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment