简体   繁体   English

Google API人员的问题:: AddContact

[英]Issue with Google API People :: AddContact

I have implemented the Google API in PHP as a service and using the Google_Service_ServicePeople() to add a contact. 我已经在PHP中实现了Google API作为服务,并使用Google_Service_ServicePeople()添加了联系人。 That works and I am getting back a proper result as a paople object. 那行得通,而我正以适当的对象返回正确的结果。 In addition when I call the people_connections->listPeopleConnections method I am getting back the contacts that I have created in my tests. 另外,当我调用people_connections-> listPeopleConnections方法时,我将获得在测试中创建的联系人。 However, when I go to contacts.google.com no contact will be shown. 但是,当我访问contacts.google.com时,将不会显示任何联系人。

Maybe it is a missunderstanding from my site, but I thought that based on the appsettings on my account, the new contacts will be created (added) to my account, won't they? 也许这是我网站上的一个误会,但我认为,根据我帐户上的应用设置,新联系人将被创建(添加)到我的帐户中,不是吗?

$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);

The response looks like: 响应如下所示:

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
                            )

... ...

Using the 使用

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

lists all the created contacts as expected. 列出所有创建的联系人,按预期方式。

But on my contacts.google.com page no contact will be shown. 但是在我的contacts.google.com页面上,不会显示任何联系人。 I am logged in as the same user I have created and granted access to the API. 我以与创建该API相同的用户身份登录。

Any ideas, hwy the contacts won't be shonw on contacts.google.com? 有什么想法,联系人不会在contacts.google.com上显示吗?

Many thanks! 非常感谢!

After several tries it wasn't possible for me to get it solved. 经过几次尝试,我无法解决它。 Therefore I have tried it now via the RapidWeb Solution. 因此,我现在已经通过RapidWeb解决方案进行了尝试 Now it is working and "the setup" with a guide - even though it tooks also 3 steps of getting the right account in place - is simple. 现在,它可以正常工作了,并且有了指南的“设置”非常简单,尽管它花了3个步骤来确定正确的帐户。 The main problem I had is to understand the logfic of OAuth2 and their possibilities to setup the correct OAuth2 Client. 我遇到的主要问题是了解OAuth2的logfic及其设置正确OAuth2客户端的可能性。 In my case I needed to setup a Native Client (just choose "Other" as ApplicationType on the second screen in the Google API Console after creating a new OAuth2 ClientId) 就我而言,我需要设置一个本机客户端(在创建新的OAuth2 ClientId之后,只需在Google API控制台的第二个屏幕上选择“其他”作为ApplicationType)

Anyway. 无论如何。 Many thanks for all who tried to help me! 非常感谢所有试图帮助我的人! Much appreciated! 非常感激!

Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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