Created
September 4, 2012 00:09
-
-
Save tcelestino/3615124 to your computer and use it in GitHub Desktop.
Permissions app on page tab Facebook
This file contains hidden or 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 | |
require 'sdk/facebook.php'; | |
$fb = new Facebook(array( | |
'appId' => 'APP_ID', | |
'secret' => 'SECRET_APP_ID', | |
)); | |
$user = $fb->getUser(); | |
if ($user) { | |
try { | |
$profile = $fb->api('/me'); | |
} catch (FacebookApiException $e) { | |
error_log($e); | |
$user = null; | |
} | |
} | |
if($user) { | |
$logoutUrl = $fb->getLogoutUrl(); | |
} else { | |
$app_id = $fb->getAppID(); // id da app | |
//seto as permissões app | |
$loginUrl = $fb->getLoginUrl( | |
array( | |
"scope" => "email, user_photos, read_friendlist", | |
"redirect_uri" => "https://www.facebook.com/pages/YOU_PAGE/ID_PAGE?sk=app_".$app_id | |
)); | |
die ('<script type="text/javascript">top.location.href="' . $loginUrl . '";</script>'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment