Before we go about retrieving data we should probably decide what data we wish to visualize. The amount of data which is available about the logged in user is not all that great (at least it isn't for me but I hardly use Facebook). That leaves us with looking at our friends. I found devices my friends use to access Facebook to be quite interesting. Are they more Android users or iOS? This information is available as part of the friends' collection. To retrieve this information we can use the FB.api()
method:
FB.api('/me?fields=friends.fields(devices)', function(response){ for(i = 0; len = response.friends.data.length; i< len; i++){ var friend = response.friends.data[i]; if(friend.devices) for(j = 0; j< friend.devices.length; j++) if(friend.devices[j].hardware != "iPad") operatingSystems[friend.devices[j].os]++; } });
Into the api()
method we pass a URL to be retrieved. In this case, we request the special URL /me
which refers to the currently...