I’ve spent some time trying to figure out how to import Google/Gmail Contacts to a web application I’m working on. It’s really easy, you’ve different ways and tools to do that.
The Javascript version is really easy to implement, a few of lines of code and you’re ready.
But the problem is with the PHP version, because Google doesn’t provides an official client library, they just points you to Zend Gdata library, which is great, but some parts are missing (like in our case Contacts).
Another problem is to make secure calls, to avoid the warning message Google shows you at the moment of grant permissions to the library:

To solve this problem we need to make the Google connection secure, and for this we need to create our own private certificate and key.
In a *nix machine (Linux/Mac) you simply type in your Terminal:
(You can use your own data in the -subj, or leave it as it is, but you NEED to change the domain name, in this case ‘yourdomain.com’).
This will generate two privately signed files:
myrsakey.pem: which is your private key.
and myrsacert.pem: your certificate.
Now you need to register your domain in Google, to allow secure connections between your server and Google, without annoying warning messages. For this, go to: https://www.google.com/accounts/ManageDomains login with your Google Account, and then add the domain name in the box:

Then, go to Manage yourdomain.com, at the bottom of this page.
And in the first field enter the URL of the script that will login and get the contacts, for example: http://yourdomain.com/contacts.php

Next, we will add the certificate file we created in before (the one called myrsacert.pem) and click on Save. After that, you’ll notice that near the upload field a new message is added saying: We have a certificate for your domain.
Ok, ready for the domain management in Google.
Now, let’s see how the PHP version works.
First of all, we need to download Zend Gdata library. And add it to the same folder where you going to execute your PHP script. (Just upload the Zend folder, from the lib folder).
Also upload your private key, myrsakey.pem somewhere in your web server, and add the absolute path to the file in the line #40 of the script.
Ok, now, this is the example to fetch all the user’s contacts and print them to screen. It’s pretty well inline documented, and if you have any concern just leave me a comment.
I will post soon about Live and Yahoo! methods to get contacts.