1
votes

I used google api to fetch contacts of google account. The code that I used is http://code.google.com/p/google-api-php-client/source/browse/trunk/examples/contacts/simple.php

But when I run the code by applying my credential, it gives me the contacts but just their name. I want the contacts email address.

3

3 Answers

1
votes

I always use this to fetch gmail contacts.

http://contactsimporter.com/address-book-importer-demo.html

Hope you will like this too.

It authenticates the user on our own end, doesn't send user to authenticate to gmail.

Just give it a try.

Here's the download link.

http://svetlozar.net/downloads/import.zip

0
votes

You can find how to fetch emails on this link, the problem was on the example code. This is part of the code refered in the link.

    $req = new \apiHttpRequest("https://www.google.com/m8/feeds/contacts/default/full?max-results=9999");
    $val = $client->getIo()->authenticatedRequest($req);

    $xml = new \SimpleXMLElement($val->getResponseBody());
    $xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
    $result = $xml->xpath('//gd:email');

    foreach($result as $title)
    {
            $emails[] = $title->attributes()->address;
    }