我已将PHP API作为服务实施,并使用Google_Service_ServicePeople()添加联系人。这是有效的,我正在取回一个适当的结果作为paople对象。此外,当我调用people_connections-> listPeopleConnections方法时,我将恢复我在测试中创建的联系人。但是,当我访问contacts.google.com时,将不会显示任何联系人。
也许这是对我网站的误解,但我认为根据我帐户的appsettings,新的联系人将被创建(添加)到我的帐户,不是吗?
$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?
非常感谢!
答案 0 :(得分:0)
经过多次尝试后,我无法解决问题。因此,我现在通过RapidWeb解决方案尝试了它。现在它正在工作,并且带有指南的“设置” - 尽管它还采取了3个步骤来获得正确的帐户 - 很简单。 我遇到的主要问题是了解OAuth2的logfic以及它们设置正确的OAuth2客户端的可能性。 在我的情况下,我需要设置一个Native Client(在创建新的OAuth2 ClientId之后,只需在Google API控制台的第二个屏幕上选择“Other”作为ApplicationType)
反正。非常感谢所有试图帮助我的人!非常感谢!
干杯!