请尝试此代码,它可能对您有所帮助
public void printAllContacts()throws ServiceException, IOException {
ContactsService myService = null;
myService = new ContactsService(accessToken);//add here your access token
myService.setAuthSubToken(accessToken);//add here your access token
URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full?max-results=5000");
ContactFeed resultFeed = myService.getFeed(feedUrl, ContactFeed.class);
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
ContactEntry entry = resultFeed.getEntries().get(i);
if (entry.hasName()) {
Name name = entry.getName();
if (name.hasFullName()) {
String fullNameToDisplay = name.getFullName().getValue();
if (name.getFullName().hasYomi()) {
fullNameToDisplay += "("
+ name.getFullName().getYomi() + ")";
}
System.out.println(fullNameToDisplay);
}
for (Email email : entry.getEmailAddresses()) {
System.out.println(email.getAddress());
}
Link photoLink = entry.getContactPhotoLink();
String photoLinkHref = photoLink.getHref();
System.out.println("Photo Link:" + photoLinkHref+"\n");
}
}
}