已弃用。请改用 People API 高级服务
联系人中的即时通讯字段。
方法
方法 | 返回类型 | 简介 |
---|---|---|
get | String | 获取此字段的地址。 |
get | Object | 获取此字段的标签。 |
is | Boolean | 获取这是主字段值的确切信息。 |
set |
| 设置此字段的地址。 |
set |
| 将此字段设置为主要字段。 |
set |
| 设置此字段的标签。 |
set |
| 设置此字段的标签。 |
已弃用的方法
方法 | 返回类型 | 简介 |
---|---|---|
| void | 删除此即时通讯字段。 |
详细文档
getAddress()
获取此字段的地址。
// Logs the address for the 'Home Address' field for contact 'John Doe'.
// Can be used similarly for other fields that contain addresses.
const contacts = ContactsApp.getContactsByName('John Doe');
const homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);
Logger.log(homeAddress[0].getAddress());
返回
String
- 地址(字符串)
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.google.com/m8/feeds
getLabel()
获取此字段的标签。这可以是 Field、ExtendedField 或 String。
// Logs the label for all the address fields associated with contact
// 'John Doe'. This method can be similarly called for any field that has
// a label.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
for (let i = 0; i < addressFields.length; i++) {
Logger.log(addressFields[i].getLabel());
}
返回
Object
- 此字段的标签
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.google.com/m8/feeds
isPrimary()
获取这是主字段值的标志。
// Logs whether or not the first address field associated with contact
// 'John Doe' is labeled as primary. This method can be similarly called
// for any field.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
Logger.log(addressFields[0].isPrimary());
返回
Boolean
- 是否为主
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.google.com/m8/feeds
setAddress(address)
设置此字段的地址。
// Sets the address for the 'Home Address' field for contact 'John Doe'.
// Can be used similarly for other fields that contain addresses.
const contacts = ContactsApp.getContactsByName('John Doe');
const homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);
homeAddress[0].setAddress('123 Main St, Raleigh, NC, 27601');
参数
名称 | 类型 | 说明 |
---|---|---|
address | String | 新地址 |
返回
- this 字段,适用于链式调用IMField
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.google.com/m8/feeds
setAsPrimary()
将此字段设置为主要字段。
// Sets the first address field associated with contact 'John Doe'
// as primary. This method can be similarly called for any field.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setAsPrimary();
返回
- 用于链式调用的 this FieldValueIMField
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.google.com/m8/feeds
setLabel(field)
设置此字段的标签。
// Sets the label to 'Work' for the first address field associated
// with contact 'John Doe'. This method can be similarly called for any
// field that has a label.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setLabel(ContactsApp.Field.WORK_ADDRESS);
参数
名称 | 类型 | 说明 |
---|---|---|
field |
| 新标准标签 |
返回
- 用于链式调用的 this FieldValueIMField
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.google.com/m8/feeds
setLabel(label)
设置此字段的标签。
// Sets the label to 'Apartment' for the first address field associated
// with contact 'John Doe'. This method can be similarly called for any
// field that has a label.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setLabel('Apartment');
参数
名称 | 类型 | 说明 |
---|---|---|
label | String | 此字段的新标签 |
返回
- this 字段,适用于链式调用IMField
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.google.com/m8/feeds
已弃用的方法
deleteIMField()
deleteIMField()
已弃用。此函数已废弃,不应在新脚本中使用。
删除此即时通讯字段。
// Retrieves and deletes the AIM instant messaging field for contact 'John
// Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const imFields = contacts[0].getIMs(ContactsApp.Field.AIM);
imFields[0].deleteIMField();
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.google.com/m8/feeds