Created
July 9, 2014 11:35
-
-
Save A-gambit/fd52430720765da2563d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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