【发布时间】:2016-04-09 13:08:23
【问题描述】:
我已经能够通过 API 成功添加联系人,但我无法删除我创建的联系人。
https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/shared-contacts
function deletecontact()
{
SharedContactsApp.setOAuth2AccessToken(getSharedContactsService().getAccessToken ());
var contacts = SharedContactsApp.getContactById('5c8b05ab8c9f68c6');
SharedContactsApp.deleteContact('5c8b05ab8c9f68c6');
}
我收到以下错误消息:
TypeError: Cannot call method "getElements" of undefined. (line 200, file "Code", project "SharedContactsApp")
如何消除这个错误?
另外...
我尝试使用以下代码设置职位,但收到以下错误:
ReferenceError:"profile" 未定义。 (第 142 行,文件“代码”)
function changeJobTitle2()
{
SharedContactsApp.setOAuth2AccessToken(getSharedContactsService().getAccessToken ());
var contact = SharedContactsApp.getContactById('82f05968956d66f');
profile.setJobTitle('Google Apps Expert');
}
【问题讨论】:
-
我运行了 Peter Herrmann 在另一篇文章中提到的 tinyTest,结果恢复正常。
-
function hailmary() { SharedContactsApp.setOAuth2AccessToken(getSharedContactsService().getAccessToken()); var contact = SharedContactsApp.getContactById('82f05968956d66f'); SharedContactsApp.deleteContact(contact) }
标签: google-api google-apps google-shared-contacts