Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memberships #11

Open
priitn1 opened this issue Sep 7, 2018 · 4 comments
Open

Memberships #11

priitn1 opened this issue Sep 7, 2018 · 4 comments

Comments

@priitn1
Copy link

priitn1 commented Sep 7, 2018

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.

@paugnu
Copy link

paugnu commented Dec 11, 2018

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

@Monsieux
Copy link

Monsieux commented Dec 26, 2018

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.

@VivianaBruno
Copy link

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

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

@luisdatec
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants