I've already modified the script. But still nothing happen after i
successfully login to google account
And then go to the grant access or deny access page. After that there
is email contact has been retrieved.
Can you give me a hint how to display the email contact.
Please help me James...
Thank you...
The code Look like this:
google.load('gdata', '2.x');
google.setOnLoadCallback(initFunc);var contactsService; var scope = 'http://www.google.com/m8/feeds'; function logMeIn() { var token = google.accounts.user.login(scope); doGetInfo(scope); } If this is not called then the cookie is stored for 2 years. // Also, it is retained across browser sessions function logMeOut(){ google.accounts.user.logout(); } function handleInfo(data) { var response = eval(data.currentTarget.responseText); alert('Target: ' + response.Target + "\n" + 'Scope: ' + response.Scope + "\n" + 'Secure: ' + response.Secure); } function doGetInfo(scope) { if (google.accounts.user.checkLogin(scope)) { google.accounts.user.getInfo(handleInfo); } } function setupContactsService() { contactsService = new google.gdata.contacts.ContactsService('my- contact'); } function initFunc() { setupContactsService(); //logMeIn(); //window.alert(scope); if (google.accounts.user.checkLogin(scope)) { getMyData(); var test = document.getElementById('display'); test.appendChild(document.createTextNode(contactFeedUri)); } else { var message = "You are not logged in! Click the Login button to get your contacts."; var groupsDiv = document.getElementById ('display'); groupsDiv.appendChild(document.createTextNode (message)); } } function getMyData() { var output = ''; // The feed URI that is used for retrieving contact groups var groupFeedUri = 'http://www.google.com/m8/feeds/groups/ default/full'; // The feed URI that is used for retrieving contacts var contactFeedUri = 'http://www.google.com/m8/feeds/contacts/ default/full'; // callback method to be invoked when getContactGroupFeed() returns data var callback = function(result) { // An array of contact group entries var entries = result.feed.entry; var groupsDiv = document.getElementById('display'); var newGroupList = document.createElement('ul'); newGroupList.id = 'GROUPS'; groupsDiv.appendChild(newGroupList); // Retrieve the first entry of the contact groups array for (var g=0; g < entries.length; g++) { var groupEntry = entries[g]; var groupTitle = groupEntry.getTitle().getText (); var groupId = groupEntry.getId().getValue(); // Query for all the contacts entry with this contact group var query = new google.gdata.contacts.ContactQuery(contactFeedUri); // Use query parameter to set the group ID query.setParam('group', groupId); var groupItem = document.createElement('li'); groupItem.id = 'GROUP_' + groupId; groupItem.appendChild(document.createTextNode (groupTitle)); newGroupList.appendChild(groupItem); // callback method to be invoked when getContactFeed() returns data var printGroupMembers = function(result) { var newContactList = document.createElement('ul'); newContactList.id = 'CONTACT_LIST_' + g; groupItem.appendChild(newContactList); // An Array of contact entries 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(); var contactItem = document.createElement('li'); contactItem.id = 'CONTACT_EMAIL_' + j; contactItem.appendChild (document.createTextNode(emailAddress)); newContactList.appendChild(contactItem); } } } // Submit the request using the contacts service object contactsService.getContactFeed(query, printGroupMembers, handleError); } } if (output){ alert(output); } // Error handler var handleError = function(error) { alert('Error! ' + error); } // Submit the request using the contacts service object contactsService.getContactGroupFeed(groupFeedUri, callback, handleError); } </script> <title>Picker HTML</title> </head> <body> <!--<body onload="Picker.render('picker_container')">--> <input type="button" value="Login" onclick="logMeIn();" /> <input type="submit" name="asal2" value="logout" onClick="logMeOut ();"> <!--<div id="picker_container"></div>--> <div id="display" class="display"><p>Harusnya nanti muncul di sini!!!! </p></div> </body> </html> On Dec 2, 9:28 pm, James <[email protected]> wrote: > Don't you have to have your scope in checkLogin? > I would throw an alert statement in your if conditional to make sure > your entering it. > Like this: > > if(google.contacts.user.checkLogin(scope)) > { > getMyContacts(); > } > > On Dec 2, 1:16 am, Harliano Adelsa <[email protected]> wrote: > > > Dear Team, > > > I have a problem with google API. > > I can't display the email contact after i logged on. > > I try to copied from the example, but it seems nothing happen. > > > this the code. > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml"> > > <head> > > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> > > <script type="text/javascript" src="http://www.google.com/jsapi"></script> > > <script type="text/javascript" language="javascript"> > > //google.load('gdata', '1.x'); > > var contactsService; > > > function setupContactsService() > > { > > contactsService = new > > google.gdata.contacts.ContactsService('exampleCo-exampleApp-1.0'); > > > } > > > function logMeIn() > > { > > var scope = 'http://www.google.com/m8/feeds'; > > var token = google.accounts.user.login(scope); > > > } > > > function initFunc() > > { > > //window.alert("Testing"); > > setupContactsService(); > > logMeIn(); > > if(google.contacts.user.checkLogin()) > > { > > getMyContacts(); > > } > > > } > > > function logMeOut() > > { > > google.accounts.user.logout(); > > > } > > > function getMyContacts() > > { > > var contactsFeedUri = > > 'http://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(5); > > > 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('email = ' + emailAddress); > > } > > }} > > > function handleError(e) { > > //alert("There was an error!"); > > alert(e.cause ? e.cause.statusText : e.message); > > > } > > > //google.setOnLoadCallback(initFunc); > > //google.load('gdata', '2.0'); > > google.load('gdata', '2.x', {packages: ['contacts']}); > > </script> > > <title>Picker HTML</title> > > </head> > > > <body> > > > <!--<body onload="Picker.render('picker_container')">--> > > <input type="button" value="Login" onclick="initFunc();" /> > > <!--<input type="submit" name="asal2" value="logout" > > onClick="logMeOut();">--> > > <div id="picker_container"></div> > > </body> > > </html> > > > please help me out team... > > > thanks, > > > harliano -- You received this message because you are subscribed to the Google Groups "Google Contacts API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-contacts-api?hl=en.
