Created
October 10, 2012 14:59
-
-
Save automata/3866159 to your computer and use it in GitHub Desktop.
fb heads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- detalhes importantes: é preciso informar uma API KEY em FB.init() e além disso essa página tem que estar rodando no domínio que foi especificado no seu cadastro de app --> | |
| <html> | |
| <head> | |
| <title>[-_-] heads [o_o]</title> | |
| </head> | |
| <body> | |
| <div id="fb-root"></div> | |
| <div id="login"></div> | |
| <div id="console"></div> | |
| <div id="profile_pics"></div> | |
| <script src="http://connect.facebook.net/en_US/all.js"></script> | |
| <script> | |
| FB.init({ | |
| appId : '000000000000', // YOUR API KEY HERE!!! | |
| status : true, // check login status | |
| cookie : true, // enable cookies to allow the server to access the session | |
| xfbml : true // parse XFBML | |
| }); | |
| FB.Event.subscribe('auth.sessionChange', function(response) { | |
| window.location.reload(); | |
| }); | |
| FB.getLoginStatus(function(response) { | |
| if (response.status === "connected") { | |
| var profilePicsDiv = document.getElementById('profile_pics'); | |
| var consoleDiv = document.getElementById('console'); | |
| FB.api("/me/friends?fields=name,picture", function(result) { | |
| var friends = result.data; | |
| console.log(friends); | |
| var markup = ''; | |
| if (friends.length > 0) { | |
| consoleDiv.innerHTML = '<b>'+friends.length+' friends...</b>'; | |
| for (var i=0; i<friends.length; i++) { | |
| markup += "<img src=\"" + friends[i].picture + "\" />"; | |
| } | |
| } | |
| profilePicsDiv.innerHTML = markup; | |
| //FB.XFBML.parse(profilePicsDiv); | |
| //console.log(profilePicsDiv.innerHTML); | |
| }); | |
| document.getElementById('login').innerHTML | |
| ='<a href="#" onclick="FB.logout();">Logout</a><br/>'; | |
| } else { | |
| document.getElementById('login').innerHTML | |
| ='<fb:login-button show-faces="true" width="200"' | |
| + ' max-rows="1" perms="user_likes, friends_likes">' | |
| + '</fb:login-button>'; | |
| FB.XFBML.parse(); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment