O'Reilly logo

Data Visualization: Representing Information on Modern Web by Swizec Teller, Ændrew Rininsland, Simon Timms, Andy Kirk

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

Retrieving data

As with Facebook, we could do manual authentication against the OAuth 2.0 endpoint, but let's make use of Google's provided API. Hooking it up is very simple:

document.addEventListener("DOMContentLoaded",
 function() {
    var po = document.createElement('script');
    po.type = 'text/javascript'; po.async = true;
    po.src = 'https://plus.google.com/js/client:plusone.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(po, s);
  });

This runs once the document is ready and loads the API script from Google's servers by placing a new script tag on the page just before the tag including jQuery. The loaded document contains a number of JavaScript functions that can be used to interact with Google APIs but not specifically ...

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