0
|
1 <?php
|
|
2
|
|
3 /**
|
|
4 * Getting SubscribedTo and Subscribers via Graph API
|
|
5 *
|
|
6 * @author Xavier Barbosa
|
|
7 * @since 13 February, 2013
|
|
8 * @link https://developers.facebook.com/blog/post/638/
|
|
9 **/
|
|
10
|
|
11 use Mute\Facebook\App;
|
|
12
|
|
13 /**
|
|
14 * Default params
|
|
15 **/
|
|
16
|
|
17 $app_id = "YOUR_APP_ID";
|
|
18 $app_secret = "YOUR_APP_SECRET";
|
|
19 $my_url = "YOUR_URL";
|
|
20
|
|
21 /**
|
|
22 * The process
|
|
23 **/
|
|
24
|
|
25 $app = new App($app_id, $app_secret);
|
|
26 $code = $_REQUEST["code"];
|
|
27
|
|
28 if (empty($code)) {
|
|
29 $dialog_url = $app->getOAuth()->getCodeURL($my_url, array('user_subscriptions'));
|
|
30
|
|
31 echo "<script> top.location.href=" . json_encode($dialog_url) . "</script>";
|
|
32 }
|
|
33 else {
|
|
34 $params = $app->getOAuth()->getAccessToken($code);
|
|
35 $subscribedto_resp_obj = $app->get('me/subscribedto', array(
|
|
36 'access_token' => $params['access_token'],
|
|
37 ));
|
|
38 $subscribedto = $subscribedto_resp_obj['data'];
|
|
39
|
|
40 print_r($subscribedto);
|
|
41 }
|