Facebook oauth cannot log out that does not accept permissions

I have a facebook application that runs in a kiosk in my restaurant, this allows users to register. This works great if they enter the system and accept the necessary permissions, then they exit the system when they are executed without the slightest problem.

If, however, they do not accept the permission, the method of registration will not work. I tried everything I could think of, and every post I could find on stackoverflow.

How can I register a client if auth does not have user permission?

I reported this to facebook using a bug report, they said they were studying it. I just hope that one of the geniuses here had an idea.

+5
source share
1 answer

You should use the permissions mix in the api graphic to determine if the user has provided specific perms. if they don’t, you can use the same thing as the condition to display the login button or stream with an added area.

example coming: includes, current php sdk and current js sdk with html5 login button.

* In the example, I use manage_pages as the required permission. *

PHP SDK 3.2.2 init

 require '../../src/facebook.php';
 $facebook = new Facebook(array(
   'appId'  => '1111111111111111',
   'secret' => 'xxxxxxxxxxxxxxxx',
   'cookie' => true, // enable optional cookie support
   ));
try { $user = $facebook->getUser(); } catch (FacebookApiException $e) {  };

PHP code:

if ($user) {
  try {
    // Proceed knowing you have a logged in user who authenticated.
    $user_accounts = $facebook->api('/me/?fields=permissions');
  } catch (FacebookApiException $e) {
   error_log($e);
   $user = null;
  }
}

PHP Terms and HTML5 Login Button

        <div id="fb-root"></div>
        <script>// current js sdk</script>
<?php if($user && !$user_accounts[permissions][data][0][manage_pages]): ?>
// we know we have a user but no perms so lets render button with out scope.
    <div class="fb-login-button" data-autologoutlink="true" data-show-faces="false" data-width="200" data-max-rows="1" data-size="large"></div>
<?php elseif($user && $user_accounts[permissions][data][0][manage_pages]): ?>
// we know we have a user and they have given perms so render button with scope.
    <div class="fb-login-button" data-autologoutlink="true" data-show-faces="false" data-width="200" data-max-rows="1" data-size="large" data-scope="manage_pages"></div>
<?php elseif(!$user): ?>
// we have no user, flow as new user... or provide 2 buttons lol.
    <div class="fb-login-button" data-autologoutlink="true" data-show-faces="false" data-width="200" data-max-rows="1" data-size="large" data-scope="manage_pages"></div>
<?php endif; ?>
+1
source

All Articles