| 12345 |
anikendra |
1 |
<div id="fb-root"></div>
|
|
|
2 |
<script src="//connect.facebook.net/en_US/all.js"></script>
|
|
|
3 |
<script>
|
|
|
4 |
FB.init({
|
|
|
5 |
appId : '<?php echo $fbappid;?>',
|
|
|
6 |
status : true, // check login status
|
|
|
7 |
cookie : true, // enable cookies to allow the server to access the session
|
|
|
8 |
xfbml : true // parse XFBML
|
|
|
9 |
});
|
|
|
10 |
</script>
|
|
|
11 |
|
|
|
12 |
<script>
|
|
|
13 |
/*
|
|
|
14 |
<?php if(!empty($logged_user)):?>
|
|
|
15 |
var loggedIn = true;
|
|
|
16 |
<?php else:?>
|
|
|
17 |
var loggedIn = false;
|
|
|
18 |
<?php endif;?>
|
|
|
19 |
|
|
|
20 |
FB.Event.subscribe('auth.login', function(response) {
|
|
|
21 |
if (response.authResponse) {
|
|
|
22 |
console.log("logged user "+response.authResponse.accessToken);
|
|
|
23 |
// FB.api('/me', function(response) {
|
|
|
24 |
if(!loggedIn){
|
|
|
25 |
window.location = '<?php echo $base_url;?>users/checkfbuser/'+response.authResponse.accessToken;
|
|
|
26 |
loggedIn = true;
|
|
|
27 |
}
|
|
|
28 |
// });
|
|
|
29 |
}
|
|
|
30 |
});
|
|
|
31 |
|
|
|
32 |
FB.Event.subscribe('auth.statusChange',function(response) {
|
|
|
33 |
if (response.status === 'connected') {
|
|
|
34 |
// the user is logged in and connected to your
|
|
|
35 |
// app, and response.authResponse supplies
|
|
|
36 |
// the user's ID, a valid access token, a signed
|
|
|
37 |
// request, and the time the access token
|
|
|
38 |
// and signed request each expire
|
|
|
39 |
var uid = response.authResponse.userID;
|
|
|
40 |
var accessToken = response.authResponse.accessToken;
|
|
|
41 |
console.log("auth status change "+accessToken+' uid = '+uid);
|
|
|
42 |
if(!loggedIn){
|
|
|
43 |
window.location = '<?php echo $base_url;?>users/checkfbuser/'+accessToken;
|
|
|
44 |
}
|
|
|
45 |
} else if (response.status === 'not_authorized') {
|
|
|
46 |
// the user is logged in to Facebook,
|
|
|
47 |
//but not connected to the app
|
|
|
48 |
} else {
|
|
|
49 |
// the user isn't even logged in to Facebook.
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
);
|
|
|
53 |
*/
|
|
|
54 |
</script>
|