views:

280

answers:

3

I know how to get the entire contacts list using Google Contacts API (I get a session token and use Google's Zend package for PHP).

But how can I get the person's name and email address? Currently, the Contacts API just seems to give all of the contacts. I'm not sure how to distinguish which email and name out of that list corresponds to the user's account.

Is there an easy way to get the user's full name and email address?

Any help would be useful. Thanks!

A: 

If you ask for the "default" contact (i.e., me), you get what you need. Mind that you need to write default with a lowercase d and not as written in the documentation.

idophir
A: 

yes goto http://code.google.com/apis/contacts/docs/3.0/reference.html#ContactsFeed and see the "Contacts feed" they say to use the Default, it worked for me after using the default - lower case only.

request

http://www.google.com/m8/feeds/contacts/default/full

will give you the user's details.

http://www.google.com/m8/feeds/contacts/[email protected]/full

will give you a contact info (if [email protected]) is a contact.

Roy
A: 

THe xml returned for the default contact list will have the user's name and email within the "author" element. I don't know PHP, but the code might look something like this...

  email = xml["author"].first["email"].first
  name = xml["author"].first["name"].first
David Knight