Search code examples
phpgoogle-contacts-api

how to grab gmail contact list after user gets authenticated with oauth2


After getting user authenticated with oauth2, i got the token. so how that get request should be to retrieve user's gmail contact list in php ?

here is the code for oauth2

session_start();

require_once 'src/apiClient.php';


$client = new apiClient();

$client->setClientId('CLIENTID');
$client->setClientSecret('CLIENTSECRET');
$client->setRedirectUri('URI');
$client->setApplicationName("NAME");
$client->setScopes("http://www.google.com/m8/feeds/");
if (isset($_SESSION['access_token'])) {
  $client->setAccessToken($_SESSION['access_token']);
} else {
  $client->setAccessToken($client->authenticate());
}
$_SESSION['access_token'] = $client->getAccessToken();

print($_SESSION['access_token']);

then how can i get contact list of user ?

Thank you


Solution

  • You were reading the right document. But refer the section Client Libraries and Sample Code for sample code.

    Also, check the link http://gdatatips.blogspot.com/2008/11/2-legged-oauth-in-php.html

    I can see that the example uses Google contacts list API retrieval.