rapidwebltd / php-google-people-api

👥 This package provides a user friendly way of interacting with Google Contacts via the Google People API.
GNU Lesser General Public License v3.0
100 stars 39 forks source link

How to add phone number with a contact? #12

Closed frdev closed 5 years ago

frdev commented 5 years ago

Please, help me!

paugnu commented 5 years ago

Here you have a mostly complete example:

$contact = new Contact($people); $contact->names[0] = new stdClass; $contact->names[0]->givenName = 'Test Name'; $contact->names[0]->familyName = 'Family Name'; $contact->emailAddresses[0] = new stdClass; $contact->emailAddresses[0]->value = 'your_email@yourcompany.com'; $contact->phoneNumbers[0] = new stdClass; $contact->phoneNumbers[0]->value = '666888999'; $contact->organizations[0] = new stdClass; $contact->organizations[0]->name = 'Your Company'; $contact->addresses[0] = new stdClass; $contact->addresses[0]->streetAddress = 'Your Street'; $contact->addresses[0]->city = 'Your City'; $contact->addresses[0]->region = 'Region'; $contact->addresses[0]->postalCode = '11111'; $contact->addresses[0]->country = 'IN'; $contact->save();

nantoniadis commented 5 years ago

Hello,

$contact->save() returns 1 when successful. Is there any way to get the resourceName? eg "people/c4722530053606681048".

We need this in order to keep updating the contact in the future.

Thank you in advance

nantoniadis commented 5 years ago

I found the solution. On apidwebltd\php-google-people-api\src\Contact.php I changed line 22 from "return true" to "return $this->resourceName;".

Monsieux commented 5 years ago

I found the solution. On apidwebltd\php-google-people-api\src\Contact.php I changed line 22 from "return true" to "return $this->resourceName;".

You can also do this withou editing the source code:

After saving the Contact with $contact->save(); You can get the output.

$contact->save();
$resourceName = $contact->resourceName;
echo $resourceName;