Google API 人员问题 :: AddContact

Issue with Google API People :: AddContact

我在 PHP 中实现了 Google API 作为服务,并使用 Google_Service_ServicePeople() 添加联系人。这行得通,我得到了一个正确的结果作为一个 paople 对象。此外,当我调用 people_connections->listPeopleConnections 方法时,我会取回我在测试中创建的联系人。但是,当我转到 contacts.google.com 时,不会显示联系人。

也许这是我网站的误解,但我认为根据我帐户上的应用程序设置,新联系人将被创建(添加)到我的帐户中,不是吗?

$client = new Google_Client();
$client->setApplicationName ('VABS-CONTACT-TEST');
$client->setAuthConfig($_SERVER['DOCUMENT_ROOT'].'/includes/classes/Google/auth.json');
$client->addScope (Google_Service_Peopleservice::CONTACTS);

$peopleService = new Google_Service_PeopleService($client);

$person = new Google_Service_PeopleService_Person();
$name = new Google_Service_People_Name();
$name->setDisplayName ('FirstName LastName');
$name->setFamilyName ('LastName');
$name->setGivenName('FirstName');

$email = new Google_Service_People_EmailAddress();
$email->value = 'xxx@xxx.xx';

$person->setNames ($name);
$person->setEmailAddresses ($email);

$result = $peopleService->people->createContact ($person);

响应如下:

Google_Service_PeopleService_Person Object
(
[collection_key:protected] => userDefined
[addressesType:protected] => Google_Service_PeopleService_Address
[addressesDataType:protected] => array
[ageRange] => 
[ageRangesType:protected] => Google_Service_PeopleService_AgeRangeType
[ageRangesDataType:protected] => array
[biographiesType:protected] => Google_Service_PeopleService_Biography
[biographiesDataType:protected] => array
[birthdaysType:protected] => Google_Service_PeopleService_Birthday
[birthdaysDataType:protected] => array
[braggingRightsType:protected] => Google_Service_PeopleService_BraggingRights
[braggingRightsDataType:protected] => array
[coverPhotosType:protected] => Google_Service_PeopleService_CoverPhoto
[coverPhotosDataType:protected] => array
[emailAddressesType:protected] => Google_Service_PeopleService_EmailAddress
[emailAddressesDataType:protected] => array
[etag] => %Eh8BAgMEBQYHCAkKCwwNDg8QERITFBUWFzUZNDciJScuGgwBAgMEBQYHCAkKCwwiDFFrVXd2SnRpTFZZPQ==
[eventsType:protected] => Google_Service_PeopleService_Event
[eventsDataType:protected] => array
[gendersType:protected] => Google_Service_PeopleService_Gender

。 . . . ( )

[modelData:protected] => Array
    (
        [metadata] => Array
            (
                [sources] => Array
                    (
                        [0] => Array
                            (
                                [type] => CONTACT
                                [id] => 494c65970e1a12eb
                                [etag] => #QkUwvJtiLVY=
                                [updateTime] => 2018-04-04T13:58:27.710001Z
                            )

...

使用

$peopleService->people_connections->listPeopleConnections('people/me',$options)

按预期列出所有已创建的联系人。

但是在我的 contacts.google.com 页面上不会显示联系人。我以我创建并授予访问 API.

的同一用户身份登录

任何想法,为什么联系人不会显示在 contacts.google.com 上?

非常感谢!

经过多次尝试,我无法解决问题。因此,我现在已经通过 RapidWeb 解决方案进行了尝试。现在它正在运行,并且 "the setup" 有一个指南 - 即使它也需要 3 个步骤来获得正确的帐户 - 很简单。 我遇到的主要问题是了解 OAuth2 的逻辑及其设置正确的 OAuth2 客户端的可能性。 在我的例子中,我需要设置一个本地客户端(在创建新的 OAuth2 ClientId 后,只需在 Google API 控制台的第二个屏幕上选择 "Other" 作为 ApplicationType)

无论如何。非常感谢所有试图帮助我的人!非常感谢!

干杯!