简体   繁体   中英

Google People API in PHP

I try to implement People API, after successfully OAuth2, when try to load people, error is:

Undefined property: Google_Service_People_Resource_People::$connections

This is lines who produce error:

$people_service = new Google_Service_People($client);
$connections = $people_service->people->connections->listConnections('people/me');

Am going by this tutorial https://developers.google.com/people/v1/getting-started , and this: https://developers.google.com/people/v1/requests .

Thanks

我想您正在寻找...

$connections = $people_service->people_connections->listPeopleConnections('people/me');

We've written a PHP Google People API library that might help. It makes implementing access to Google Contacts via the Google People API much easier than using Google's own library.

Link: https://github.com/rapidwebltd/php-google-people-api

Example Usage

Usage

Retrieve all contacts

// Retrieval all contacts
foreach($people->all() as $contact) {
    echo $contact->resourceName.' - ';
    if ($contact->names) {
        echo $contact->names[0]->displayName;
    }
    echo PHP_EOL;
}

Retrieve a single contact

// Retrieve single contact (by resource name)
$contact = $people->get('people/c8055020007701654287');

Create a new contact

// 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();

Update a contact

// Update contact
$contact->names[0]->familyName = 'McTest';
$contact->save();

Delete a contact

// Delete contact
$contact->delete();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM