I am very new to FaceBook Javascript API. I need help to get the fiends list according to the Friend List i have created. Like 'Grads, School, Friends, Worked with' (All of these are self created).
This is so far I have done right now. I am successfully logged in and have proper access_token allocated to this session. After that I run this.
FB.login(function(response) {
if( response.session ){
*FB.api('friendlist', '/me/friendlists', function(){
**alert('got the friendlist');
});
}else{
alert('User not logged in.');
}
},{scope: 'email,read_friendlists'});
On this code
* this runs OK without any exceptions?
** this alert never invokes?
Just want to ask few things.
Is there a proper way to see the exception. If we have a callback for exception as well?
and How to get the List of FriendList from FB using JS API.
Thanks,
Talha Ahmed khan
I've tried this and it seems to work
<div id="listsDiv"></div>
<script>
var listsDiv = document.getElementById('listsDiv');
FB.getLoginStatus(function(response) {
if (response.status != 'connected') {
listsDiv.innerHTML = '<em>You are not connected</em>';
return;
}
});
var perms = function(){
FB.api('/me/friendlists', function(result) {
var markup = '';
var lists = result.data;
for(var i in lists){
markup += lists[i].name +'<br />';
}
listsDiv .innerHTML = markup;
});
}
FB.login(perms, { scope: 'read_friendlists' });
</script>
You can test a lot of this stuff out at