簡體   English   中英

PHP中的Google People API

[英]Google People API in PHP

我嘗試實現People API, 成功執行 OAuth2后,當嘗試加載人員時,錯誤是:

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

謝謝

我想您正在尋找...

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

我們已經編寫了一個可能有幫助的PHP Google People API庫。 與使用Google自己的庫相比,通過Google People API實現對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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM