Mercurial > nebulaweb3
diff default/assets/vendors/theme-widgets/vendor/mute/facebook/example/handling-revoked-permissions.php @ 0:1d038bc9b3d2 default tip
Up:default
author | Liny <dev@neowd.com> |
---|---|
date | Sat, 31 May 2025 09:21:51 +0800 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/default/assets/vendors/theme-widgets/vendor/mute/facebook/example/handling-revoked-permissions.php Sat May 31 09:21:51 2025 +0800 @@ -0,0 +1,49 @@ +<?php + +/** + * The Permissions that are requested from a User by an App may not be fully + * granted, or may not remain constant - a user can choose to not grant some + * Permissions and can revoke these Permissions afterwards through their + * Facebook account settings. In order to provide a positive user experience, + * Apps should be built to handle these situations. + * + * @author Xavier Barbosa + * @since 13 February, 2013 + * @link https://developers.facebook.com/docs/howtos/login/handling-revoked-permissions/ + **/ + +use Mute\Facebook\App; +use Mute\Facebook\Exception\GraphAPIException; + +/** + * Default params + **/ + +$app_id = "YOUR_APP_ID"; +$app_secret = "YOUR_APP_SECRET"; +$access_token = 'USER_ACCESS_TOKEN'; +$user_id = 'USER_ID'; + +/** + * Step 1. Detecting Granted Permissions + **/ + +$app = new App($app_id, $app_secret); +$permissions = $app->get($user_id . '/permissions', array( + 'access_token' => $access_token, +)); + +var_dump($permissions); + +/** + * Step 2. Failing Gracefully When Encountering Missing Permissions + **/ + +try { + $app->post('me/socialhiking:hike', array( + 'access_token' => $access_token, + 'hike' => 'http://samples.ogp.me/338293766265387', + )); +} catch (GraphAPIException $e) { + var_dump($e->getData); +}