PHP code example of rams007 / php-google-people-api
1. Go to this page and download the library: Download rams007/php-google-people-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rams007 / php-google-people-api example snippets
$people = new GooglePeople($googleOAuth2Handler);
// Retrieval all contacts
foreach($people->all() as $contact) {
echo $contact->resourceName.' - ';
if ($contact->names) {
echo $contact->names[0]->displayName;
}
echo PHP_EOL;
}
// Retrieve single contact (by resource name)
$contact = $people->get('people/c8055020007701654287');
// Create new contact
$contact = new Contact($people);
$contact->names[0] = new stdClass;
$contact->names[0]->givenName = 'Testy';
$contact->names[0]->familyName = 'McTest Test';
$contact->save();