0
|
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 }
|