Skip to content

Instantly share code, notes, and snippets.

@A-gambit
Created July 9, 2014 11:35
Show Gist options
  • Select an option

  • Save A-gambit/fd52430720765da2563d to your computer and use it in GitHub Desktop.

Select an option

Save A-gambit/fd52430720765da2563d to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
{{js "demo"}}
<script src="https://apis.google.com/js/client.js?onload=load"></script>
</head>
<body class="load">
<img style="position:absolute; top: -1000px;">
<input type="button" value="Login" onclick="login()"/>
<div id="profile"></div>
</body>
</html>
<!--
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("gdata", "1.x");
</script>
<script type="text/javascript">
var contactsService;
var scope = 'https://www.google.com/m8/feeds';
function setupContactsService()
{
contactsService = new google.gdata.contacts.ContactsService('GoogleInc-jsguide-1.0');
}
function logMeIn()
{
var token = google.accounts.user.login(scope);
}
function initFunc()
{
setupContactsService();
if (google.accounts.user.checkLogin(scope))
{
getMyContacts();
}
else
{
logMeIn();
}
}
function getMyContacts()
{
var contactsFeedUri = 'https://www.google.com/m8/feeds/contacts/default/full';
var query = new google.gdata.contacts.ContactQuery(contactsFeedUri);
// Set the maximum of the result set to be 5
query.setMaxResults(1);
contactsService.getContactFeed(query, handleContactsFeed, handleError);
}
var handleContactsFeed = function (result)
{
var entries = result.feed.entry;
for (var i = 0; i < entries.length; i++)
{
var contactEntry = entries[i];
var emailAddresses = contactEntry.getEmailAddresses();
for (var j = 0; j < emailAddresses.length; j++)
{
var emailAddress = emailAddresses[j].getAddress();
alert(emailAddress);
}
}
}
function handleError(e)
{
alert("There was an error!" + (e.cause ? e.cause.statusText : e.message));
}
function logMeOut()
{
google.accounts.user.logout();
}
</script>
</head>
<body>
<input type="button" onclick="initFunc();" value="Test" />
<script type="text/javascript">
if (google.accounts.user.checkLogin(scope))
{
setupContactsService();
getMyContacts();
}
</script>
</body>
</html>
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment