forked from marcelkalveram/facebook-tab-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
139 lines (90 loc) · 4.02 KB
/
index.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
require_once('facebook-sdk/facebook.php');
require_once('inc/config.php');
// create facebook object
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
'cookie' => true
));
// get signed request
$signedRequest = $facebook->getSignedRequest();
$userIsFan = isset($signedRequest['page']['liked']) && $signedRequest['page']['liked'];
// language detection, check if user has locale set to German
$language_DE = ($signedRequest['user']['locale'] == 'de_DE');
?>
<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8" lang="en" xmlns="http://www.w3.org/1999/xhtml"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--><html class="no-js" lang="en"><!--<![endif]-->
<html>
<head>
<!-- Title of Facebook Tab -->
<title>Facebook Tab Title</title>
<!-- SET character set and chrome frame for IE6 -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- include stylesheet (taken from HTML5 boilerplate) -->
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- Wrapper that encloses the entire content -->
<div id="wrapper">
<!-- YOUR CONTENT GOES HERE -->
<div id="content">
<?php
/* ---------------------------------------------*/
/* ------- CONTENT FOR GERMAN VISITORS -------- */
/* ---------------------------------------------*/
if ($language_DE) { ?>
<!-- ********** THIS CAN BE VIEWED BY FANS ONLY ********** -->
<?php if ($userIsFan) { ?>
<p>Benutzer ist ein Fan</p>
<!-- ********** THIS CAN BE VIEWED BY NON-FANS ONLY ********** -->
<?php } else { ?>
<p>Benutzer ist kein Fan</p>
<?php }
}
/* ---------------------------------------------*/
/* ------- CONTENT FOR ENGLISH VISITORS ------- */
/* ---------------------------------------------*/
else { ?>
<!-- ********** THIS CAN BE VIEWED BY FANS ONLY ********** -->
<?php if ($userIsFan) { ?>
<p>User is a fan</p>
<!-- ********** THIS CAN BE VIEWED BY FANS ONLY ********** -->
<?php } else { ?>
<p>User is not a fan</p>
<?php } ?>
<?php } ?>
</div>
</div>
<!-- FB Root serves as anchor for the FB javascript SDK -->
<!-- Must not be changed or removed -->
<div id="fb-root"></div>
<script>
// Called when FB SDK has been loaded
window.fbAsyncInit = function() {
// Initialize the FB javascript SDK
FB.init({
appId : '<?php echo APP_ID; ?>',
status : true,
cookie : true,
xfbml : true
});
// Auto grows panel when app is higher than 800px.
// In the app settings, height needs to be set to height 800px fixed for this to work
FB.Canvas.setSize({ width: 810, height: 1417 });
//FB.Canvas.setAutoGrow();
};
// Load the SDK Asynchronously
(function (d) {
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
} (document));
</script>
</body>
</html>