已淘汰。請改用 People API 進階服務
ContactGroup 是一組聯絡人。
已淘汰的方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
|
| 將指定聯絡人新增至這個群組
// The code below creates a new contact and adds it to the "Work Friends" // contact group const contact = ContactsApp.createContact( 'John', 'Doe', 'john.doe@example.com', ); const group = ContactsApp.getContactGroup('Work Friends'); group.addContact(contact); |
| void | 刪除這個聯絡人群組。 |
|
| 取得這個聯絡人群組中的所有聯絡人。 |
| String | 傳回這個群組的名稱。 |
| String | 取得這個聯絡人群組的 ID。 |
| String | 取得這個聯絡人群組的名稱。 |
| Boolean | 取得布林值,判斷這個聯絡人群組是否為系統群組 (無法刪除)。 |
|
| 將指定聯絡人從這個群組中移除// The code below retrieves all the contacts named "John Doe' and removes them // from the "Work Friends" contact group const contacts = ContactsApp.getContactsByName('John Doe'); const group = ContactsApp.getContactGroup('Work Friends'); for (const i in contacts) { group.removeContact(contacts[i]); } |
| void | 設定這個群組的名稱。 |
|
| 設定這個聯絡人群組的名稱。 |
已淘汰的方法
addContact(contact)
addContact(contact)
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
將指定聯絡人新增至這個群組
// The code below creates a new contact and adds it to the "Work Friends" // contact group const contact = ContactsApp.createContact( 'John', 'Doe', 'john.doe@example.com', ); const group = ContactsApp.getContactGroup('Work Friends'); group.addContact(contact);
參數
名稱 | 類型 | 說明 |
---|---|---|
contact |
| 要加入群組的聯絡人 |
回攻員
:這個聯絡人群組Contact
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
另請參閱
deleteGroup()
deleteGroup()
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
刪除這個聯絡人群組。
只會刪除非系統群組,系統群組無法刪除。
// The code below retrieves a contact group named "Work Friends" and deletes it const group = ContactsApp.getContactGroup('Work Friends'); group.deleteGroup();
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
另請參閱
getContacts()
getContacts()
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
取得這個聯絡人群組中的所有聯絡人。
// The code below retrieves all the contacts in the group named "Work Friends" const group = ContactsApp.getContactGroup('Work Friends'); const contacts = group.getContacts();
回攻員
:這個群組中的聯絡人Contact[]
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
getGroupName()
getGroupName()
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
傳回這個群組的名稱。
回攻員
String
:這個群組的名稱
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
getId()
getId()
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
取得這個聯絡人群組的 ID。
// The code below retrieves a contact group named "Work Friends" and gets its id const group = ContactsApp.getContactGroup('Work Friends'); const id = group.getId();
回攻員
String
:這個群組的 ID
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
getName()
getName()
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
取得這個聯絡人群組的名稱。
// The code below creates a new contact group and then retrieves its name const group = ContactsApp.createContactGroup('Work Friends'); const name = group.getName();
回攻員
String
:這個聯絡人群組的名稱
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
另請參閱
isSystemGroup()
isSystemGroup()
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
取得布林值,判斷這個聯絡人群組是否為系統群組 (無法刪除)。
系統群組是指 Google 聯絡人中預先定義的一組群組,例如「我的聯絡人」、「家人」、「同事」等。系統群組的名稱通常會包含「系統群組」字樣。
// The code below retrieves two contact groups, then logs whether or not // each is a system group. const myGroup = ContactsApp.getContactGroup('Work Friends'); const systemGroup = ContactsApp.getContactGroup('System Group: Coworkers'); Logger.log(myGroup.isSystemGroup()); // Returns false, if the group exists. Logger.log(systemGroup.isSystemGroup()); // Returns true.
回攻員
Boolean
:這個聯絡人群組是否為系統群組
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
removeContact(contact)
removeContact(contact)
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
將指定聯絡人從這個群組中移除
// The code below retrieves all the contacts named "John Doe' and removes them // from the "Work Friends" contact group const contacts = ContactsApp.getContactsByName('John Doe'); const group = ContactsApp.getContactGroup('Work Friends'); for (const i in contacts) { group.removeContact(contacts[i]); }
參數
名稱 | 類型 | 說明 |
---|---|---|
contact |
| 要從群組中移除的聯絡人 |
回攻員
:這個聯絡人群組Contact
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
另請參閱
setGroupName(name)
setGroupName(name)
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
設定這個群組的名稱。
參數
名稱 | 類型 | 說明 |
---|---|---|
name | String | 要為這個群組設定的名稱 |
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
setName(name)
setName(name)
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
設定這個聯絡人群組的名稱。
// The code below retrieves the contact group named "Work Friends" and renames // it to "Work Buddies" const group = ContactsApp.getContactGroup('Work Friends'); group.setName('Work Buddies');
參數
名稱 | 類型 | 說明 |
---|---|---|
name | String | 聯絡人群組的新名稱 |
回攻員
:這個聯絡人群組Contact
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds