Hi Julian, The only problem I was able to find was that you are using a GoogleService, if you change that object to a com.google.gdata.client.contacts.ContactsService it should work.
Cheers, Julian On Mar 3, 12:03 pm, Julian <[email protected]> wrote: > The following code connects correctly and returns names, but fails to > return email addresses for a contacts feed that contains them. Can > anyone explain why? > > --- > > package test; > > import static > com.google.gdata.client.contacts.ContactsService.CONTACTS_SERVICE; > > import java.io.IOException; > import java.net.URL; > > import com.google.gdata.client.GoogleService; > import com.google.gdata.data.contacts.ContactEntry; > import com.google.gdata.data.contacts.ContactFeed; > import com.google.gdata.data.contacts.GroupMembershipInfo; > import com.google.gdata.data.extensions.Email; > import com.google.gdata.data.extensions.EventFeed; > import com.google.gdata.data.extensions.ExtendedProperty; > import com.google.gdata.data.extensions.Im; > import com.google.gdata.util.ServiceException; > > public class Test { > > /** > * @param args > * @throws ServiceException > * @throws IOException > */ > public static void main(String[] args) throws IOException, > ServiceException { > // Set up the URL and the object that will handle the > connection: > URL feedUrl = new > URL("http://www.google.com/m8/feeds/contacts/ > [email protected]/full"); > > GoogleService myService = new GoogleService(CONTACTS_SERVICE, > "xxx"); > myService.setUserCredentials("[email protected]", "xxx"); > > // Mark the feed as an Event feed: > new > EventFeed().declareExtensions(myService.getExtensionProfile()); > > // Send the request and receive the response: > ContactFeed resultFeed = myService.getFeed(feedUrl, > ContactFeed.class); > > System.out.println(resultFeed.getTitle().getPlainText()); > for (int i = 0; i < resultFeed.getEntries().size(); i++) { > ContactEntry entry = resultFeed.getEntries().get(i); > System.out.println("\t" + > entry.getTitle().getPlainText()); > > System.out.println("Email addresses:"); > > for (Email email : entry.getEmailAddresses()) { > System.out.print(" " + email.getAddress()); > if (email.getRel() != null) { > System.out.print(" rel:" + email.getRel()); > } > if (email.getLabel() != null) { > System.out.print(" label:" + email.getLabel()); > } > if (email.getPrimary()) { > System.out.print(" (primary) "); > } > System.out.print("\n"); > } > > System.out.println("IM addresses:"); > for (Im im : entry.getImAddresses()) { > System.out.print(" " + im.getAddress()); > if (im.getLabel() != null) { > System.out.print(" label:" + im.getLabel()); > } > if (im.getRel() != null) { > System.out.print(" rel:" + im.getRel()); > } > if (im.getProtocol() != null) { > System.out.print(" protocol:" + im.getProtocol()); > } > if (im.getPrimary()) { > System.out.print(" (primary) "); > } > System.out.print("\n"); > } > > System.out.println("Groups:"); > for (GroupMembershipInfo group : > entry.getGroupMembershipInfos > ()) { > String groupHref = group.getHref(); > System.out.println(" Id: " + groupHref); > } > > System.out.println("Extended Properties:"); > for (ExtendedProperty property : > entry.getExtendedProperties()) > { > if (property.getValue() != null) { > System.out.println(" " + property.getName() + > "(value) = " > + > property.getValue()); > } else if (property.getXmlBlob() != null) { > System.out.println(" " + property.getName() + > "(xmlBlob)= " > + > property.getXmlBlob().getBlob()); > } > } > ContactEntry contact = entry; > if (contact.getContactPhotoLink() != null) { > String photoLink = > contact.getContactPhotoLink().getHref(); > System.out.println("Photo Link: " + > photoLink); > > //if (photoLink.getEtag() != null) { > if (photoLink != null) { > System.out.println("Contact Photo's > ETag: " + photoLink); > } > > System.out.println("Contact's ETag: " + > contact.getEtag()); > } > } > } > > } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
