How to retrieve contacts in GMAIL-CSV format?

392 views
Skip to first unread message

Luis

unread,
Aug 6, 2012, 9:31:09 PM8/6/12
to google-co...@googlegroups.com
Hi,
     I want to retrieve all my Google contacts with a script. I know I must retrieve
after authentication. No problem with that, except that it is a xml file....
How can I retrieve the GMAIL-CSV version?

Thanks!

     L.

Luis

unread,
Aug 12, 2012, 8:27:31 AM8/12/12
to google-co...@googlegroups.com
No one? :(

devzh

unread,
Oct 16, 2012, 12:09:32 PM10/16/12
to google-co...@googlegroups.com
Am Sonntag, 12. August 2012 14:27:31 UTC+2 schrieb Luis:
No one? :(


Did you ever figured this out? I need this as well.

Thanks,
Marco
 

Warren Vail

unread,
Oct 18, 2012, 4:36:26 PM10/18/12
to google-co...@googlegroups.com
OK, I've had some success in PHP with https://developers.google.com/google-apps/contacts/v3/reference, but I found that in addition to specifying the max-results parameter, I needed to include &v=3.0  (specifying the api version to gain access to the contacts first and last name).

I also found that PHP's xml parsing provided by simpleXMLLoad did not completely parse the XML in the response, it appears simpleXMLLoad doesn't  consider tagnames that contain colons (as in gd:email) as valid.  The workaround for this was to use the PHP xml_parse modules where you code your own start_tag and end_tag routines to identify the beginning and end of a tag, and a middle_tag routine to get at the information between the beginning and end of a tag (the start_tag function will have access to any attributes for the tag).  From there you should be able to create your own CSV file with the contents.

One Warning.  Many of my contacts were quite old (some came from GMail when it was a separate service), so the data seemed like garbage.  For example out of 26 contacts only 11 had both a first and last name, and only 9 had email addresses.  Many of the email addresses had no name at all, possibly because some of my newer contacts had not yet shared anything with me.

good luck,

Luis A. Florit

unread,
Oct 18, 2012, 8:15:58 PM10/18/12
to google-co...@googlegroups.com
Yes, this is the only way I found also, ie, to process the xml file.

Thanks!

L.

* El 18/10/12 a las 13:36, Warren Vail chamullaba:

> OK, I've had some success in PHP
> with https://developers.google.com/google-apps/contacts/v3/reference, but I
> found that in addition to specifying the max-results parameter, I needed to
> include &v=3.0 (specifying the api version to gain access to the contacts
> first and last name).
>
> I also found that PHP's xml parsing provided by simpleXMLLoad did not
> completely parse the XML in the response, it appears simpleXMLLoad doesn't
> consider tagnames that contain colons (as in gd:email) as valid. The
> workaround for this was to use the PHP xml_parse modules where you code
> your own start_tag and end_tag routines to identify the beginning and end
> of a tag, and a middle_tag routine to get at the information between the
> beginning and end of a tag (the start_tag function will have access to any
> attributes for the tag). From there you should be able to create your own
> CSV file with the contents.
>
> One Warning. Many of my contacts were quite old (some came from GMail when
> it was a separate service), so the data seemed like garbage. For example
> out of 26 contacts only 11 had both a first and last name, and only 9 had
> email addresses. Many of the email addresses had no name at all, possibly
> because some of my newer contacts had not yet shared anything with me.
>
> good luck,
>
> On Monday, August 6, 2012 6:31:09 PM UTC-7, Luis wrote:
> >
> > Hi,
> > I want to retrieve all my Google contacts with a script. I know I
> > must retrieve
> > *https://www.google.com/m8/feeds/contacts/default/full?max-results=9999*
> > after authentication. No problem with that, except that it is a xml
> > file....
> > How can I retrieve the GMAIL-CSV version?
> >
> > Thanks!
> >
> > L.
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
> To post to this group, send email to
> google-co...@googlegroups.com
> To unsubscribe from this group, send email to
> google-contacts...@googlegroups.com
> For more options, visit this group at
> http://code.google.com/apis/contacts/community/forum.html

--
My gallery: http://luis.impa.br/photo

Brave Dave

unread,
Oct 19, 2012, 2:54:14 AM10/19/12
to google-co...@googlegroups.com
You Little beauty
  • v=3.0 is exactly what I needed
    • Once v=3.0 is added the q parameter works
Thanks Warren
Reply all
Reply to author
Forward
0 new messages