comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:1d038bc9b3d2
1 <?php
2
3 /**
4 * The Permissions that are requested from a User by an App may not be fully
5 * granted, or may not remain constant - a user can choose to not grant some
6 * Permissions and can revoke these Permissions afterwards through their
7 * Facebook account settings. In order to provide a positive user experience,
8 * Apps should be built to handle these situations.
9 *
10 * @author Xavier Barbosa
11 * @since 13 February, 2013
12 * @link https://developers.facebook.com/docs/howtos/login/handling-revoked-permissions/
13 **/
14
15 use Mute\Facebook\App;
16 use Mute\Facebook\Exception\GraphAPIException;
17
18 /**
19 * Default params
20 **/
21
22 $app_id = "YOUR_APP_ID";
23 $app_secret = "YOUR_APP_SECRET";
24 $access_token = 'USER_ACCESS_TOKEN';
25 $user_id = 'USER_ID';
26
27 /**
28 * Step 1. Detecting Granted Permissions
29 **/
30
31 $app = new App($app_id, $app_secret);
32 $permissions = $app->get($user_id . '/permissions', array(
33 'access_token' => $access_token,
34 ));
35
36 var_dump($permissions);
37
38 /**
39 * Step 2. Failing Gracefully When Encountering Missing Permissions
40 **/
41
42 try {
43 $app->post('me/socialhiking:hike', array(
44 'access_token' => $access_token,
45 'hike' => 'http://samples.ogp.me/338293766265387',
46 ));
47 } catch (GraphAPIException $e) {
48 var_dump($e->getData);
49 }