创建共享联系人
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
设置身份验证后,您可以使用 Domain Shared Contacts API 将新的共享联系人条目发布到 Google Workspace 网域。共享的联系人最长可能需要 24 小时才能显示在电子邮件地址自动补全功能和联系人管理器中。
创建您要发布的共享联系人的 XML 表示形式,该表示形式应为 Contact kind(联系人类型)的 Atom <entry>
元素,可能类似于以下内容:
<atom:entry xmlns:atom='http://www.w3.org/2005/Atom'
xmlns:gd='http://schemas.google.com/g/2005'>
<atom:category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/contact/2008#contact' />
<gd:name>
<gd:givenName>FIRST_NAME</gd:givenName>
<gd:familyName>LAST_NAME</gd:familyName>
<gd:fullName>FIRST_NAME LAST_NAME</gd:fullName>
</gd:name>
<atom:content type='text'>NOTES</atom:content>
<gd:email rel='http://schemas.google.com/g/2005#work'
primary='true'
address='PRIMARY_EMAIL_ADDRESS' displayName='PREFERRED_NAME' />
<gd:email rel='http://schemas.google.com/g/2005#home'
address='SECONDARY_EMAIL_ADDRESS' />
<gd:phoneNumber rel='http://schemas.google.com/g/2005#work'
primary='true'>
PRIMARY_PHONE_NUMBER
</gd:phoneNumber>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#home'>
SECONDARY_PHONE_NUMBER
</gd:phoneNumber>
<gd:im address='INSTANT_MESSAGING_ADDRESS'
protocol='http://schemas.google.com/g/2005#GOOGLE_TALK'
primary='true'
rel='http://schemas.google.com/g/2005#home' />
<gd:structuredPostalAddress
rel='http://schemas.google.com/g/2005#work'
primary='true'>
<gd:city>CITY_NAME</gd:city>
<gd:street>ADDRESS</gd:street>
<gd:region>REGION_NAME</gd:region>
<gd:postcode>POST_CODE</gd:postcode>
<gd:country>COUNTRY_NAME</gd:country>
<gd:formattedAddress>
FORMATTED_ADDRESS
</gd:formattedAddress>
</gd:structuredPostalAddress>
</atom:entry>
替换以下内容:
FIRST_NAME
:所分享联系人的名字,例如 Alex。
LAST_NAME
:要共享的联系人的姓氏,例如“Kim”。
PRIMARY_EMAIL_ADDRESS
:共享联系人的首选电子邮件地址,例如 alk@gmail.com。
PREFERRED_NAME
:向用户显示的名称,例如 Alex Kim
SECONDARY_EMAIL_ADDRESS
:共享联系人的另一个电子邮件地址,例如 alk@example.org。
PRIMARY_PHONE_NUMBER
:共享联系人的首选电话号码,例如 (800) 555-0100。
SECONDARY_PHONE_NUMBER
:所分享联系人的另一个电话号码,例如 (800) 555-0101。
INSTANT_MESSAGING_ADDRESS
:与所分享联系人的即时通讯信息关联的电子邮件地址,例如 alk@gmail.com。
CITY_NAME
:共享联系人的城市名称,例如山景城。
ADDRESS
:共享联系人的街道地址,例如 1600 Amphibious Blvd。
REGION_NAME
:共享联系人的州或省级行政区,例如 CA。
POST_CODE
:共享联系人的邮政编码,例如 94045。
COUNTRY_NAME
:共享联系人的所在国家/地区,例如美国。
FORMATTED_ADDRESS
:共享联系人的地址,采用其所在国家/地区的惯例设置格式,例如 1800 Amphibious Blvd Mountain View。
如需发布此条目,请将其发送到联系人名单 Feed 网址:
- 使用
application/atom+xml
内容类型将 Atom <entry>
元素放入新的 POST
请求正文中。
- 向 Feed 网址发送
POST
请求。
例如,如需将网域共享联系人添加到 example.com 所属的列表,请将包含新条目的 POST
请求发送到以下网址:
https://www.google.com/m8/feeds/contacts/example.com/full
Google 服务器会使用您发送的条目创建联系人,然后返回 HTTP 201 CREATED
状态代码以及新联系人的副本(采用 <entry>
元素的形式)。返回的条目与您发送的条目相同,但还包含服务器添加的各种元素,例如 <id>
元素。
如果您的请求失败,Google 可能会返回其他状态代码。如需了解状态代码,请参阅 Google Data API 协议参考文档。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-25。
[null,null,["最后更新时间 (UTC):2025-03-25。"],[],[],null,["# Create shared contacts\n\nAfter\n[setting up authentication](https://developers.google.com/workspace/guides/auth-overview),\nyou can use the Domain Shared Contacts API to publish new shared contact entries to a\nGoogle Workspace domain. Shared contacts can take up to 24 hours to\nappear in the email address autocomplete and the contact manager.\n\n1. Create an XML representation of the shared contact that you want to\n publish in the form of an Atom `\u003centry\u003e` element of the\n [Contact kind](https://developers.google.com/gdata/docs/2.0/elements#gdContactKind),\n which might look similar to the following:\n\n ```xml\n \u003catom:entry xmlns:atom='http://www.w3.org/2005/Atom'\n xmlns:gd='http://schemas.google.com/g/2005'\u003e\n \u003catom:category scheme='http://schemas.google.com/g/2005#kind'\n term='http://schemas.google.com/contact/2008#contact' /\u003e\n \u003cgd:name\u003e\n \u003cgd:givenName\u003eFIRST_NAME\u003c/gd:givenName\u003e\n \u003cgd:familyName\u003eLAST_NAME\u003c/gd:familyName\u003e\n \u003cgd:fullName\u003eFIRST_NAME LAST_NAME\u003c/gd:fullName\u003e\n \u003c/gd:name\u003e\n \u003catom:content type='text'\u003eNOTES\u003c/atom:content\u003e\n \u003cgd:email rel='http://schemas.google.com/g/2005#work'\n primary='true'\n address='PRIMARY_EMAIL_ADDRESS' displayName='PREFERRED_NAME' /\u003e\n \u003cgd:email rel='http://schemas.google.com/g/2005#home'\n address='SECONDARY_EMAIL_ADDRESS' /\u003e\n \u003cgd:phoneNumber rel='http://schemas.google.com/g/2005#work'\n primary='true'\u003e\n PRIMARY_PHONE_NUMBER\n \u003c/gd:phoneNumber\u003e\n \u003cgd:phoneNumber rel='http://schemas.google.com/g/2005#home'\u003e\n SECONDARY_PHONE_NUMBER\n \u003c/gd:phoneNumber\u003e\n \u003cgd:im address='INSTANT_MESSAGING_ADDRESS'\n protocol='http://schemas.google.com/g/2005#GOOGLE_TALK'\n primary='true'\n rel='http://schemas.google.com/g/2005#home' /\u003e\n \u003cgd:structuredPostalAddress\n rel='http://schemas.google.com/g/2005#work'\n primary='true'\u003e\n \u003cgd:city\u003eCITY_NAME\u003c/gd:city\u003e\n \u003cgd:street\u003eADDRESS\u003c/gd:street\u003e\n \u003cgd:region\u003eREGION_NAME\u003c/gd:region\u003e\n \u003cgd:postcode\u003ePOST_CODE\u003c/gd:postcode\u003e\n \u003cgd:country\u003eCOUNTRY_NAME\u003c/gd:country\u003e\n \u003cgd:formattedAddress\u003e\n FORMATTED_ADDRESS\n \u003c/gd:formattedAddress\u003e\n \u003c/gd:structuredPostalAddress\u003e\n \u003c/atom:entry\u003e\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eFIRST_NAME\u003c/var\u003e: First name of the shared contact---for example, Alex.\n - \u003cvar translate=\"no\"\u003eLAST_NAME\u003c/var\u003e: The last name of the shared contact---for example, Kim.\n - \u003cvar translate=\"no\"\u003ePRIMARY_EMAIL_ADDRESS\u003c/var\u003e: The preferred email address of the shared contact---for example, alk@gmail.com.\n - \u003cvar translate=\"no\"\u003ePREFERRED_NAME\u003c/var\u003e: The name that is displayed for the user---for example, Alex Kim\n - \u003cvar translate=\"no\"\u003eSECONDARY_EMAIL_ADDRESS\u003c/var\u003e: Another email address for the shared contact---for example, alk@example.org.\n - \u003cvar translate=\"no\"\u003ePRIMARY_PHONE_NUMBER\u003c/var\u003e: The preferred phone number for the shared contact---for example, (800) 555-0100.\n - \u003cvar translate=\"no\"\u003eSECONDARY_PHONE_NUMBER\u003c/var\u003e: Another phone number for the shared contact---for example, (800) 555-0101.\n - \u003cvar translate=\"no\"\u003eINSTANT_MESSAGING_ADDRESS\u003c/var\u003e: The email address associated with the shared contact's instant messaging information---for example, alk@gmail.com.\n - \u003cvar translate=\"no\"\u003eCITY_NAME\u003c/var\u003e: The city name for the shared contact---for example, Mountain View.\n - \u003cvar translate=\"no\"\u003eADDRESS\u003c/var\u003e: The street address for the shared contact---for example, 1600 Amphibious Blvd.\n - \u003cvar translate=\"no\"\u003eREGION_NAME\u003c/var\u003e: The state or province for the shared contact---for example, CA.\n - \u003cvar translate=\"no\"\u003ePOST_CODE\u003c/var\u003e: The ZIP or postal code for the shared contact---for example, 94045.\n - \u003cvar translate=\"no\"\u003eCOUNTRY_NAME\u003c/var\u003e: The country for the shared contact---for example, United States.\n - \u003cvar translate=\"no\"\u003eFORMATTED_ADDRESS\u003c/var\u003e: The address of the shared contact that is formatted using the convention of their country or region---for example,1800 Amphibious Blvd Mountain View.\n2. To publish this entry, send it to the contact-list feed URL:\n\n 1. Place your Atom `\u003centry\u003e` element in the body of a new `POST` request by using the `application/atom+xml` content type.\n 2. Send the `POST` request to the feed URL.\n\n For example, to add a domain shared contact to the list belonging to\n example.com, send the `POST` request with the new entry to the following\n URL: \n\n https://www.google.com/m8/feeds/contacts/example.com/full\n\n The Google server creates a contact by using the entry that you sent, then\n returns an `HTTP 201 CREATED` status code, along with a copy of the new\n contact in the form of an `\u003centry\u003e` element. The entry returned is the same\n one that you sent, but it also contains various elements added by the\n server, such as an `\u003cid\u003e` element.\n\n If your request fails, Google might return a different\n status code. For information about the status codes, see the\n [Google Data API protocol reference document](https://developers.google.com/gdata/docs/2.0/reference).\n\nNext steps\n----------\n\n- [Update or delete a photo for a shared contact](/workspace/admin/domain-shared-contacts/update-delete-photo-shared-contacts)"]]