我尝试在成功 OAuth2之后实施People API,当尝试加载人员时,错误是:
Undefined property: Google_Service_People_Resource_People::$connections
这是产生错误的行:
$people_service = new Google_Service_People($client);
$connections = $people_service->people->connections->listConnections('people/me');
按照本教程https://developers.google.com/people/v1/getting-started进行, 而这:https://developers.google.com/people/v1/requests。
由于
答案 0 :(得分:5)
我认为你在寻找......
$connections = $people_service->people_connections->listPeopleConnections('people/me');
答案 1 :(得分:0)
我们编写了一个可能有用的PHP Google People API库。它使通过Google People API实现对Google通讯录的访问比使用Google自己的库更容易。
链接:https://github.com/rapidwebltd/php-google-people-api
// 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();
// Update contact
$contact->names[0]->familyName = 'McTest';
$contact->save();
// Delete contact
$contact->delete();