Ragarding Google Contact V3 API

31 views
Skip to first unread message

Amar Shiva Prasad

unread,
Aug 7, 2012, 8:53:26 AM8/7/12
to google-app...@googlegroups.com
Hi All,

I am using Google Contact V3 API to get all the contacts from my gmail account. Its a normal Gmail account (user...@gmail.com). So I started from scratch I just cleaned all my contacts and I inserted 20 contacts using CSV insertion was successfully. I inserted contacts not programatically I used gmail UI only.

Here I wrote one sample main method to retrieve all contacts. I got all the 20 contacts when I ran the program at first time. And again I inserted same data in google contacts. Now my contact list increased to 40. So we have duplicates thats not a problem for testing. So I again ran the same program now instead of getting all the records I got only 25 records.

So here is my problem Why I can't get all the 40 records....?
I got only 25 records. Here I am pasting my sample code.


Sample Code:
package google.contact;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import com.google.gdata.client.ClientLoginAccountType;
import com.google.gdata.client.contacts.ContactsService;
import com.google.gdata.data.Link;
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.ExtendedProperty;
import com.google.gdata.data.extensions.Im;
import com.google.gdata.data.extensions.Name;
import com.google.gdata.util.ServiceException;

public class CopyOfTest {
    public static void printAllContacts(ContactsService myService)
            throws ServiceException, IOException {
        String inputUrl = "https://www.google.com/m8/feeds/contacts/default/full";
        // Request the feed
        // URL feedUrl = new URL(
        // "https://www.google.com/m8/feeds/contacts/default/full");
        URL feedUrl = new URL(inputUrl);
        ContactFeed resultFeed = myService.getFeed(feedUrl, ContactFeed.class);
        // Print the results
        System.out.println(resultFeed.getTitle().getPlainText());
        System.out.println(resultFeed.getEntries().size());
        System.out.println("Email addresses:");
        for (ContactEntry entry : resultFeed.getEntries()) {
            Name name = entry.getName();
            System.out.println(name.getFullName());
            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.print("\n");
            }
        }
    }

    public static ContactEntry retrieveContact(ContactsService myService)
            throws MalformedURLException, IOException, ServiceException {
        ContactEntry contact = myService
                .getEntry(
                        new URL(
                                "https://www.google.com/m8/feeds/contacts/default/full/2885d2d289f6ef41"),
                        ContactEntry.class);
        // Do something with the contact.
        Name name = contact.getName();
        System.out.println(name.getFullName());
        return contact;
    }

    public static void main(String[] args) throws ServiceException, IOException {
        ContactsService contactsService = new ContactsService("Sample");
        contactsService.setUserCredentials("username",
                "password");
//        CopyOfTest.printAllContacts(contactsService);
        CopyOfTest.retrieveContact(contactsService);
    }
}


So please help me on this why I didn't get all the records. So I stuck here... Please help me on this...

Thanks In Advance...

Thanks & Regards,
Amar.
Reply all
Reply to author
Forward
0 new messages