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,
));
try { $user = $facebook->getUser(); } catch (FacebookApiException $e) { };
PHP code:
if ($user) {
try {
$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></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; ?>
source
share