已弃用。请改用 People API 高级服务
联系人中的即时通讯字段。
方法
方法 | 返回类型 | 简介 |
---|---|---|
get | String | 获取相应字段的地址。 |
get | Object | 获取相应字段的标签。 |
is | Boolean | 获取相应值是否为主要字段值。 |
set |
| 设置相应字段的地址。 |
set |
| 将此字段设置为主要字段。 |
set |
| 设置相应字段的标签。 |
set |
| 设置相应字段的标签。 |
详细文档
get Address()
获取相应字段的地址。
// 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
get Label()
获取相应字段的标签。可以是 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
is Primary()
获取相应值是否为主字段值。
// 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
set Address(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 | 新地址 |
返回
- 此字段,用于链式调用IMField
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.google.com/m8/feeds
set As Primary()
将此字段设置为主要。
// 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();
返回
- 用于链式调用的 FieldValueIMField
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.google.com/m8/feeds
set Label(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 |
| 新标准标签 |
返回
- 用于链式调用的 FieldValueIMField
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.google.com/m8/feeds
set Label(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 | 相应字段的新标签 |
返回
- 此字段,用于链式调用IMField
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.google.com/m8/feeds