rapidwebltd/php-google-people-api

Memberships

priitn1 opened this issue · 4 comments

The whole Google API is a bit confusing in naming their properties.
What I would like to do is after adding a new Contact it would also have a predefined "Label" to it on the Google Contacts page.

What I gather is that the "Labels" are defined under the Contacts object memberships[] value?
People API says it's read-only and it's also not under the UPDATE_PERSON_FIELDS constant.

I found something called contactGroups but im not sure it's the right resource?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Hi @priitn1, did you manage to get how to do it?

I think I have a clue, but I don't have the skills to retreive data from it, because it is a nested array.

{
  "resourceName": "people/c############",
  "etag": "%EgMBNy4aDAECAwQFBgcICQoLDCI",
  "memberships": [
    {
      "metadata": {
        "source": {
          "type": "CONTACT",
          "id": "################"
        }
      },
      "contactGroupMembership": {
        "contactGroupId": "54c066"
      }
    },
    {
      "metadata": {
        "source": {
          "type": "CONTACT",
          "id": "################"
        }
      },
      "contactGroupMembership": {
        "contactGroupId": "7a2810"
      }
    },
    {
      "metadata": {
        "source": {
          "type": "CONTACT",
          "id": "2bb4fe39"
        }
      },
      "contactGroupMembership": {
        "contactGroupId": "myContacts"
      }
    }
  ]
}

Next the PHP code as described in the wiki:

$contact = $people->get('people/c############');
    echo $contact->memberships[0]->contactGroupId;

Because it is a nested array, I could not managed to echo (contactGroupId) the data.
I need this solution too, hope we can find it.

Hi!
A bit late but you can get the groupId like this:

$contact->memberships[0]->contactGroupMembership->contactGroupId

Is this work for you guys ?
$contact->memberships[0]->contactGroupMembership->contactGroupId