Retrieving all contacts with email addresses

295 views
Skip to first unread message

Stijn Meurkens

unread,
Oct 8, 2009, 10:51:17 AM10/8/09
to Google Contacts API
Hi,
I can retrieve a list of all contacts by doing a signed GET for
http://www.google.com/m8/feeds/contacts/default/full?max-results=100000

Unfortunately, this list does not include email addresses. Is it
possible to include email addresses, or do I have to fetch them one by
one?

Thanks.
Stijn

ॐ۞ ۞ ۞ |S|U||D|H |A۞ ۞ ۞ॐ

unread,
Oct 9, 2009, 1:22:02 AM10/9/09
to google-co...@googlegroups.com
Here is the code to retrieve the contact list that is only emails ...
i really dont know how to return the first name or full of the emails retrieve..


  public static void printDateMinQueryResults(ContactsService myService) {
        try {
            System.out.println("ddqq");
            // Create query and submit a request
            // URL feedUrl1 = new
            // URL("http://www.google.com/m8/feeds/contacts/rac...@gmail.com/full");
            URL feedUrl = new URL(
                    "https://www.google.com/m8/feeds/contacts/default/full");

            Query myQuery = new Query(feedUrl);
            // myQuery.setUpdatedMin(startTime);
            myQuery.setMaxResults(999999);

            ContactFeed resultFeed = myService
                    .query(myQuery, ContactFeed.class);
            System.out.println("****" + resultFeed.getTitle().getPlainText());
            List<ContactEntry> entry = resultFeed.getEntries();
            for (ContactEntry ce : entry) {
                Name dd = ce.getName();

                if (dd != null) {
                    System.out.println(dd.getFullName().getValue());

                }
                final List<Email> ee = ce.getEmailAddresses();
                final List<Im> mm = ce.getImAddresses();
                for (Im bl : mm) {
                    System.out.println("---> " + bl.getAddress());
                }

                for (Email ss : ee) {

                    System.out.println("==>" + ss.getAddress());
                }
            }

            // // Print the results
            // System.out.println(resultFeed.getTitle().getPlainText() +
            // " contacts updated on or after "
            // + startTime);
            // for (int i = 0; i < resultFeed.getEntries().size(); i++) {
            // ContactEntry entry = resultFeed.getEntries().get(i);
            // // We assume existence of a nameToPrintableString function that
            // formats
            // // the Name of a contact into a string suitable for printing.
            // List<Email> ee=entry.getEmailAddresses();
            // for(Email ss : ee) {
            // System.out.println("==>"+ss.getAddress());
            // }
            // System.out.println("\t" + entry.getName());
            //
            // }
        } catch (ServiceException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();

Julian (Google)

unread,
Oct 9, 2009, 9:20:54 AM10/9/09
to Google Contacts API
Hi,

Here is a small example that prints the contact's title and its email
addresses:

public static void printAllContacts(ContactsService contactsService)
throws ServiceException, IOException {

//Request the feed
URL feedUrl = new URL("http://www.google.com/m8/feeds/contacts/
us...@domain.com/full?max-results=10000");
ContactFeed resultFeed = contactsService.getFeed(feedUrl,
ContactFeed.class);
System.out.println(resultFeed.getEntries().size());

for (int i = 0; i < resultFeed.getEntries().size(); i++) {

ContactEntry entry = resultFeed.getEntries().get(i);

System.out.println("\n" + entry.getTitle().getPlainText());
System.out.println(" Id:" + entry.getId() );
System.out.println(" Photo:" + entry.getContactPhotoLink().getHref
() );

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");
}
}
}

On Oct 9, 6:22 am, ॐ۞ ۞ ۞ |S|U||D|H |A۞ ۞ ۞ॐ <sudhakar...@gmail.com>
wrote:
> Here is the code to retrieve the contact list that is only emails ...
> i really dont know how to return the first name or full of the emails
> retrieve..
>
>   public static void printDateMinQueryResults(ContactsService myService) {
>         try {
>             System.out.println("ddqq");
>             // Create query and submit a request
>             // URL feedUrl1 = new
>             // URL("
> http://www.google.com/m8/feeds/contacts/racn...@gmail.com/full");

ॐ۞ ۞ ۞ |S|U||D|H |A۞ ۞ ۞ॐ

unread,
Oct 14, 2009, 6:18:28 AM10/14/09
to google-co...@googlegroups.com
no i am not getting the display name jullia

Julian (Google)

unread,
Oct 18, 2009, 3:10:28 PM10/18/09
to Google Contacts API
Hi,

Please try the code in the following page to see if that helps:
http://code.google.com/apis/contacts/docs/3.0/developers_guide_java.html#Retrieving

Cheers,
Julian

On Oct 14, 11:18 am, ॐ۞ ۞ ۞ |S|U||D|H |A۞ ۞ ۞ॐ <sudhakar...@gmail.com>
wrote:
> no i am not getting the display name jullia
>
> On Fri, Oct 9, 2009 at 6:50 PM, Julian (Google) <j...@google.com> wrote:
>
> > Hi,
>
> > Here is a small example that prints the contact's title and its email
> > addresses:
>
> > public static void printAllContacts(ContactsService contactsService)
> >        throws ServiceException, IOException {
>
> > //Request the feed
> > URL feedUrl = new URL("http://www.google.com/m8/feeds/contacts/
> > u...@domain.com/full?max-results=10000");

chung cheewai

unread,
Oct 20, 2009, 6:17:32 AM10/20/09
to Google Contacts API
i try ur way oready but also cant retrieve a list of all contact. y?


On Oct 8, 10:51 pm, Stijn Meurkens <meurk...@gmail.com> wrote:
> Hi,
> I can retrieve a list of all contacts by doing a signed GET forhttp://www.google.com/m8/feeds/contacts/default/full?max-results=100000
Reply all
Reply to author
Forward
0 new messages