Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 更新谷歌域名共享联系人照片_Google Apps Script_Google Api_Google People - Fatal编程技术网

Google apps script 更新谷歌域名共享联系人照片

Google apps script 更新谷歌域名共享联系人照片,google-apps-script,google-api,google-people,Google Apps Script,Google Api,Google People,我正在使用Google Apps脚本访问域共享联系人,并使用People API更新联系人信息 我能够通过以下方式成功地将联系人照片添加到授权用户联系人中: var photoClass = {photoBytes: Utilities.base64EncodeWebSafe(testIDPhotoBlob.getBytes()), personFields:'photos'}; var testId = 'people/c12345678901234' var updatePhoto = Pe

我正在使用Google Apps脚本访问域共享联系人,并使用People API更新联系人信息

我能够通过以下方式成功地将联系人照片添加到授权用户联系人中:

var photoClass = {photoBytes: Utilities.base64EncodeWebSafe(testIDPhotoBlob.getBytes()),
personFields:'photos'};
var testId = 'people/c12345678901234'
var updatePhoto = People.People.updateContactPhoto(photoClass,testId);
这将成功更新联系人照片。请注意,联系人是一个用户联系人,并且是一个带有“people/c”的人

如果我使用相同的方法更新域共享联系人:

var photoClass = {photoBytes: Utilities.base64EncodeWebSafe(testIDPhotoBlob.getBytes()),
personFields:'photos'};
var testId = 'people/d12345678901234'
var updatePhoto = People.People.updateContactPhoto(photoClass,testId);
注意联系人Id以“person/d”开头。这将返回错误:

GoogleJsonResponseException: API call to people.people.updateContactPhoto failed with error: Resource name "people/d12345678901234" is not a valid contact person resource.
域联系人的存在形式如下:

var testPersonSearch = People.People.searchDirectoryPeople({query:'Domain Contact Name',readMask:findFields,sources:['DIRECTORY_SOURCE_TYPE_DOMAIN_CONTACT']});

Returns:
{ people: 
   [ { organizations: [Object],
       names: [Object],
       phoneNumbers: [Object],
       emailAddresses: [Object],
       etag: '%xxxxxx/yyyyyyy',
       resourceName: 'people/d12345678901234"' } ],
  totalSize: 1 }
我知道旧的API/m8/feed没有正确实现此功能

如果我对SharedContactsAPI使用以下代码:

var contact = SharedContactsApp.getContactById('hexadecimalValueofContact');
console.log(contact.hasProfilePicture()); 
returns false as contact is valid but no image exists....
console.log(contact.setProfilePicture(testIDPhotoBlob));
returns null
另外,通过直接使用URLFACHAPP.fetch等使用REST API,也会产生类似的结果,表明无法找到联系人。

对于共享联系人,您需要使用 注意:

共享联系人API仅适用于外部联系人。使用此API为域用户或组创建联系信息可能会导致这些用户和组的联系信息重复,从而导致意外行为


要使用Apps脚本实现共享联系人API,可以使用开源库。该文档为您提供了如何使用它的说明和示例。

恐怕Shared Contacts API使用了旧的/m8/feed,无法正常工作。请参阅。它说:“域共享联系人API不受这些更改的影响”您好-ShareContactsAPI和/m8/feeds/即使在联系人API日落之后仍在用于域共享联系人,关键是/m8/feed和SharedContactsAPI尚未修复域共享联系人的照片,尽管它是在2013年首次编写并在2015年更新的!