Advertisement
tcelestino

Permissions app on page tab Facebook

Sep 3rd, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2. require 'sdk/facebook.php';
  3.  
  4. $fb = new Facebook(array(
  5.   'appId'  => 'APP_ID',
  6.   'secret' => 'SECRET_APP_ID',
  7. ));
  8.  
  9. $user = $fb->getUser();
  10. if ($user) {
  11.   try {
  12.     $profile = $fb->api('/me');
  13.   } catch (FacebookApiException $e) {
  14.     error_log($e);
  15.     $user = null;
  16.   }
  17. }
  18. if($user) {
  19.     $logoutUrl = $fb->getLogoutUrl();
  20. } else {
  21.     $app_id = $fb->getAppID(); // id da app
  22.  
  23.     //seto as permissões app
  24.     $loginUrl = $fb->getLoginUrl(
  25.         array(
  26.           "scope" => "email, user_photos, read_friendlist",
  27.           "redirect_uri" => "https://www.facebook.com/pages/YOU_PAGE/ID_PAGE?sk=app_".$app_id
  28.           ));
  29.       die ('<script type="text/javascript">top.location.href="' . $loginUrl . '";</script>');
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement