Tuesday, 25 July 2017

Fetch gmail contacts


script type="text/javascript" src="http://www.google.com/jsapi"></script>
     <script src="https://apis.google.com/js/client.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
      <script>
      function auth() {
      var config = {
      'client_id': '243480442475-05gg5q6tq1qv9derqadd3l4qcegusqn8.apps.googleusercontent.com',
      'scope': 'https://www.google.com/m8/feeds/'       
      };
      gapi.auth.authorize(config, function() {
      var contacts = fetch(gapi.auth.getToken());
      alert(contacts)
      });
      }
      
      function fetch(token) {
      $.ajax({
      url: 'https://www.google.com/m8/feeds/contacts/default/full?alt=json',
      dataType: 'jsonp',
      data: token
      }).done(function(data) {
      console.log(JSON.stringify(data));
      });
      }
      </script>

      

      <button onclick="auth();">GET CONTACTS FEED</button>

No comments:

Post a Comment