This repository was archived by the owner on Nov 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfacebook_module.php
More file actions
59 lines (46 loc) · 1.91 KB
/
facebook_module.php
File metadata and controls
59 lines (46 loc) · 1.91 KB
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
session_start();
echo "Communicating with facebook ...";
$app_id = "212057308863490";
$app_secret = "c46dd118cc71d9007a9062f7f9fa6b9c";
#$my_url = "http://140.247.106.97/facebook/protected.php";
#$my_url = "http://127.0.0.1:82/facebook_module.php";
#$my_url = "http://140.247.106.97/facebook_module.php";
$my_url = "https://slide-atlas.org/facebook_module.php";
if (!isset($_REQUEST['code']))
{
$_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url) . "&state="
. $_SESSION['state'] . "&scope=email,user_groups";
echo("<script> top.location.href='" . $dialog_url . "'</script>");
}
else
{
$code = $_REQUEST['code'];
$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 = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
# Get the groups information in the paginated query
$graph_url = "https://graph.facebook.com/me/groups?access_token="
. $params['access_token'];
$groups = json_decode(file_get_contents($graph_url), true);
# Get information about the user logged into facebook
$user_url = "https://graph.facebook.com/me?access_token="
. $params['access_token'];
$user = json_decode(file_get_contents($user_url), true);
# create the corredponding structure
$_SESSION['groups'] = $groups['data'];
$_SESSION['facebook'] = $user;
$_SESSION['start'] = time();
$_SESSION['last_activity'] = time();
$_SESSION['book'] = 'bev1';
$_SESSION['copyright'] = "Copyright © 2011, Charles Palmer, Beverly
Faulkner-Jones and Su-jean Seo. All rights reserved";
$_SESSION['auth'] = 'student';
header("location:access-groups.php#list");
}
?>