Google apps script 使用应用程序脚本轮询Google联系人更改
我需要检测联系人簿中的更改,不幸的是,People API没有提供此类功能。我在一些博客上读到投票是必要的。我找不到任何API可供投票。有人能建议我如何实现此功能吗?如果您的联系人数量或联系人电子邮件数量发生变化,您可以使用此类功能接收和发送电子邮件Google apps script 使用应用程序脚本轮询Google联系人更改,google-apps-script,google-contacts-api,Google Apps Script,Google Contacts Api,我需要检测联系人簿中的更改,不幸的是,People API没有提供此类功能。我在一些博客上读到投票是必要的。我找不到任何API可供投票。有人能建议我如何实现此功能吗?如果您的联系人数量或联系人电子邮件数量发生变化,您可以使用此类功能接收和发送电子邮件 function sendEmailIfContactChange() { const gObj = PropertiesService.getScriptProperties().getProperties(); const contac
function sendEmailIfContactChange() {
const gObj = PropertiesService.getScriptProperties().getProperties();
const contacts=ContactsApp.getContacts();
var n=0;
contacts.forEach((c)=>{c.getEmails().forEach((e)=>{n++;});});
if(!gObj.hasOwnProperty('contacts')) {
gObj.contacts=contacts.length;
gObj.emails=n;
PropertiesService.getScriptProperties().setProperties(gObj);
return;
} else {
let pc = gObj.contacts;
let pe = gObj.emails;
gObj.contacts = contacts.length;
gObj.emails = n;
PropertiesService.getScriptProperties().setProperties(gObj);
if(pc != contacts.length || pe != n) {
GmailApp.sendEmail(gobj.globals.privateemail,'Contacts Have Change',`Old Contact: ${pc} New Contacts: ${contacts.length} \nOld Emails: ${pe} New Emails: ${n}`);
}
}
}
您可以创建如下轮询触发器:
function createPollingTrigger() {
const ts = ScriptApp.getProjectTriggers().map(t=>t.getHandlerFunction());
if(!~ts.indexOf('sendEmaiIfContactChange')) {
ScriptApp.newTrigger('sendEmailIfContactChange').timeBased().everyHours(2).create();
}
}
目前,此功能在当前版本的Contacts API中尚不可用。您可能希望使用此链接中的说明请求此特定功能:您希望进行什么样的更改?