I am trying to retrieve all the contacts from my Gmail account. At the moment it only seems to randomly get about 25 (I have about 200 contacts in the My Contacts group). What I have noticed is that these contacts that are retrieved are all old contacts that I made a long time ago. The newer contacts don't seem to show.
OAuth2Token
token = gdata.gauth.OAuth2Token(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, scope=SCOPE, user_agent=USER_AGENT) redirect_url = token.generate_authorize_url(redirect_uri=REDIRECT_URI)
Redirect for Auth
self.redirect(redirect_url)
Auth, Get Contacts and Display
url = atom.http_core.Uri.parse_uri(self.request.uri) if 'error' in url.query: pass else: token.get_access_token(url.query) gd_client = gdata.contacts.client.ContactsClient() token.authorize(gd_client) feed = gd_client.GetContacts() for i, entry in enumerate(feed.entry): self.response.write(entry.name.full_name)
In the Developer Contacts Page the 'Running the sample code' says to use:
gd_client = gdata.contacts.data.ContactsClient(source='YOUR_APPLICATION_NAME')
But it keeps kicking out an error that the ContactsClient was not found. I eventually found it in gdata.contacts.client
.
Additional question - I have assigned USER_AGENT
with '', what am I supposed to put there?
The contacts feed returns the first 25 contacts when no query parameters are provided. Add the start-index and max-results parameters to adjust this.
https://developers.google.com/google-apps/contacts/v3/reference#Parameters
There should also be page info returned in the result indicating how many contacts are on the page, which page it is, and how many more pages there are.