O'Reilly logo

Social Data Visualization with HTML5 and JavaScript by Simon Timms

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required