如何在联系人条目中添加昵称?

发布于 2024-08-26 20:45:57 字数 200 浏览 3 评论 0 原文

我想使用 "Google.GData.Extensions.Apps" 在 Google 联系人中添加“昵称”。

我可以将昵称创建为:

NicknameElement obj_nickname = new NicknameElement(); obj_nickname.Name = "詹妮弗";

但是如何将 i 添加到联系人条目中呢?

I want to add "Nickname" in Google Contact using "Google.GData.Extensions.Apps" .

I am able to create Nickname as:

NicknameElement obj_nickname = new NicknameElement();
obj_nickname.Name = " Jenifer";

But how to add i to Contact Entry?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

顾冷 2024-09-02 20:45:58

联系人 API 支持使用 gContact:nickname 元素的昵称。此元素是 Contacts API 3.0 版本中的新增元素,因此位于 gContact 命名空间中。例如:

<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>Victor</gd:givenName>
    <gd:familyName>Fryzel</gd:familyName>
    <gd:fullName>Vic Fryzel</gd:fullName>
  </gd:name>

  <!-- ... -->

  <gContact:nickname>Vic</gContact:nickname>
</atom:entry>

幸运的是,.NET 客户端库已更新为该参数的 getter 和 setter,尽管这些方法在 .NET 开发人员指南。但是,您可以在 源代码。它们在源代码中:

因此,您可以使用以下代码来设置联系人的昵称。

Contact newContact = new Contact();
newContact.Title.Text = "Victor Fryzel";
newContact.Nickname = new Nickname("Vic");
// ...
// This example assumes the ContactRequest object (cr) is already set up.
Contact createdContact = cr.Insert(newContact);

有关详细信息,请参阅 .NET 开发人员指南。祝你好运!

The Contacts API does support nicknames using the gContact:nickname element. This element is new in version 3.0 of the Contacts API, and as such is in the gContact namespace. For example:

<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>Victor</gd:givenName>
    <gd:familyName>Fryzel</gd:familyName>
    <gd:fullName>Vic Fryzel</gd:fullName>
  </gd:name>

  <!-- ... -->

  <gContact:nickname>Vic</gContact:nickname>
</atom:entry>

Fortunately, the .NET client library has been updated with a getter and setter for this parameter, although the methods are undocumented in the .NET Developer's Guide. But, you can find them in the source code.They're in the source code here:

Thus, you can use the following code to set a contact's nickname.

Contact newContact = new Contact();
newContact.Title.Text = "Victor Fryzel";
newContact.Nickname = new Nickname("Vic");
// ...
// This example assumes the ContactRequest object (cr) is already set up.
Contact createdContact = cr.Insert(newContact);

For more information, please see the .NET Developer's Guide. Good luck!

酒中人 2024-09-02 20:45:58

为了进一步帮助其他人,

使用最新的 .net API,我需要稍微不同地设置昵称,因为我找不到 Nickname 对象。我将保持它与维克的答案类似,以扩展而不是替换它。这种方法已经过测试并且对我有用。抱歉,Vic,如果我错过了您的解决方案中的某些内容,我还无法添加评论。

Contact newContact = new Contact();
newContact.Title.Text = "Victor Fryzel";
newContact.ContactEntry.Nickname = "nicknameString";
// ...
// This example assumes the ContactRequest object (cr) is already set up.
Contact createdContact = cr.Insert(newContact);

根据文档包含命名空间。

using Google.Contacts;
using Google.GData.Contacts;
using Google.GData.Client;
using Google.GData.Extensions;

To further help others,

Using the latest .net API, I needed to set the nickname slightly differently as I couldn't find the Nickname object. I'll keep it similar to Vic's answer as to extend not replace it. This approach has been tested and works for me. Sorry Vic if I've missed something with your solution, I can't add comments yet.

Contact newContact = new Contact();
newContact.Title.Text = "Victor Fryzel";
newContact.ContactEntry.Nickname = "nicknameString";
// ...
// This example assumes the ContactRequest object (cr) is already set up.
Contact createdContact = cr.Insert(newContact);

Included namespaces as per documentation.

using Google.Contacts;
using Google.GData.Contacts;
using Google.GData.Client;
using Google.GData.Extensions;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文