-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.php
59 lines (42 loc) · 1.7 KB
/
index2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
$app_id = '478174598904856';
$app_secret = 'e7a9947ac59f9c5a264cd83f68689d80';
// $my_url = 'https://rocky-woodland-3057.herokuapp.com/';
$my_url = 'https://apps.facebook.com/santoshreddy/';
$code = $_REQUEST["code"];
require_once('php-sdk/src/facebook.php');
$config = array(
'appId' => '478174598904856',
'secret' => 'e7a9947ac59f9c5a264cd83f68689d80',
'sharedSession' => true,
'trustForwarded' => true,
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
// auth user
if(empty($code)) {
$dialog_url = 'https://www.facebook.com/dialog/oauth?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url).'&scope=friends_birthday,user_birthday,read_mailbox,friends_online_presence,user_online_presence' ;
echo("<script>top.location.href='" . $dialog_url . "'</script>");
}
// get user access_token
$token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url)
. '&client_secret=' . $app_secret
. '&code=' . $code;
// response is of the format "access_token=AAAC..."
$access_token = substr(file_get_contents($token_url), 13);
// $friendsbday = $facebook->api('/'.$user_id.'?fields=friends.fields(birthday)?access_token='.$access_token);
// echo $friendsbday;
print_r("The userID is:");
print_r($user_id);
$fql_query_url = 'https://graph.facebook.com/'
. 'fql?q=SELECT+uid2+FROM+friend+WHERE+uid1=me()'
. '&access_token=' . $access_token;
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);
echo '<pre>';
print_r("query results:");
print_r($fql_query_obj);
echo '</pre>';
?>