Search code examples
phprestapigoogle-contacts-apigoogle-people-api

Google People API / Method: contactGroups.list


This is the sample code that I am using to get my contacts from Google People API. Works fine.

$people_service = new Google_Service_PeopleService($client); // TODO: Use service object to request People data

$connections = $people_service->people_connections->listPeopleConnections ('people/me',
    array('personFields' => 'names,emailAddresses,biographies',
    'pageSize' => 25,
    'sortOrder' => 'FIRST_NAME_ASCENDING',
    ));

But I couldn't figure out how to list and manage Contact Groups (like friends, family etc.).

This is the code I am trying without success.

$groups_list = $people_service->contactGroups->listcontactGroups();

Sources I could find:


Solution

  • Have you check if you need to call an extra function as indicated in this documentation? Follow the PHP sample for printing the names for up to 10 connections.

    $groups_list = $people_service->contactGroups->listcontactGroups();
    
    $group_list->getContactGroups( );