Skip to content

Instantly share code, notes, and snippets.

@phwd
Created September 18, 2012 20:39
Show Gist options
  • Save phwd/3745712 to your computer and use it in GitHub Desktop.
Save phwd/3745712 to your computer and use it in GitHub Desktop.
Pages you own on Facebook
<fb:login-button scope="manage_pages"
onlogin="getAccounts()">
Grant Permissions to Allow access to Pages you admin
</fb:login-button>
<ul id="accounts"></ul>
<script>
window.getAccounts = pullAccounts();
function pullAccounts(){
FB.api('/me/accounts', function(response) {
Log.info('Accounts', response);
parseAccounts(response);
});
}
function parseAccounts(response) {
var ul = document.getElementById('accounts');
for (var i=0, l=response.data.length; i<l; i++) {
var account = response.data[i];
var li = document.createElement('li');
var a = document.createElement('a');
if(account.category != "Application"){
a.innerHTML = account.name;
a.href = "http://facebook.com/" + account.id;
li.appendChild(a);
ul.appendChild(li);
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment