Using the API

It is perfectly possible to manually perform OAuth to authenticate and authorize your visualization with Facebook. However, Facebook has been kind enough to provide a very usable JavaScript SDK. The API abstracts away the process of logging into a function call. To make use of the API, we first need to include it in our visualization. To do this, simply include the following script inside one of your script tags:

(function(d){
  var js;
  var id = 'facebook-jssdk';
  var ref = d.getElementsByTagName('script')[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement('script'); js.id = id; js.async = true;
  js.src = "//connect.facebook.net/en_US/all.js";
  ref.parentNode.insertBefore(js, ref);
}(document));

This code will create a new script ...

Get Data Visualization: Representing Information on Modern Web now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.