|
41 | 41 |
|
42 | 42 | ?> |
43 | 43 | <!doctype html> |
44 | | -<html> |
| 44 | +<html xmlns:fb="http://www.facebook.com/2008/fbml"> |
45 | 45 | <head> |
46 | 46 | <title>php-sdk</title> |
47 | 47 | <style> |
|
58 | 58 | </style> |
59 | 59 | </head> |
60 | 60 | <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 | + |
61 | 90 | <h1><a href="example.php">php-sdk</a></h1> |
62 | 91 |
|
63 | 92 | <?php if ($me): ?> |
64 | 93 | <a href="<?php echo $logoutUrl; ?>"> |
65 | 94 | <img src="http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif"> |
66 | 95 | </a> |
67 | 96 | <?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 & XFBML: <fb:login-button></fb:login-button> |
| 99 | + </div> |
| 100 | + <div> |
| 101 | + Without using JavaScript & 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> |
71 | 106 | <?php endif ?> |
72 | 107 |
|
73 | 108 | <h3>Session</h3> |
|
0 commit comments