Skip to content

Commit f3073bd

Browse files
committed
include JS enabled login button and background status ping in example
1 parent 1649042 commit f3073bd

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

examples/example.php

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
?>
4343
<!doctype html>
44-
<html>
44+
<html xmlns:fb="http://www.facebook.com/2008/fbml">
4545
<head>
4646
<title>php-sdk</title>
4747
<style>
@@ -58,16 +58,51 @@
5858
</style>
5959
</head>
6060
<body>
61+
<!--
62+
We use the JS SDK to provide a richer user experience. For more info,
63+
look here: http://github.com/facebook/connect-js
64+
-->
65+
<div id="fb-root"></div>
66+
<script>
67+
window.fbAsyncInit = function() {
68+
FB.init({
69+
appId : '<?php echo $facebook->getAppId(); ?>',
70+
status : true, // check login status
71+
cookie : true, // enable cookies to allow the server to access the session
72+
xfbml : true // parse XFBML
73+
});
74+
75+
// whenever the user logs in, we refresh the page
76+
FB.Event.subscribe('auth.login', function() {
77+
window.location.reload();
78+
});
79+
};
80+
81+
(function() {
82+
var e = document.createElement('script');
83+
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
84+
e.async = true;
85+
document.getElementById('fb-root').appendChild(e);
86+
}());
87+
</script>
88+
89+
6190
<h1><a href="example.php">php-sdk</a></h1>
6291

6392
<?php if ($me): ?>
6493
<a href="<?php echo $logoutUrl; ?>">
6594
<img src="http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif">
6695
</a>
6796
<?php else: ?>
68-
<a href="<?php echo $loginUrl; ?>">
69-
<img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif">
70-
</a>
97+
<div>
98+
Using JavaScript &amp; XFBML: <fb:login-button></fb:login-button>
99+
</div>
100+
<div>
101+
Without using JavaScript &amp; XFBML:
102+
<a href="<?php echo $loginUrl; ?>">
103+
<img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif">
104+
</a>
105+
</div>
71106
<?php endif ?>
72107

73108
<h3>Session</h3>

0 commit comments

Comments
 (0)