【问题标题】:Using Google Contacts API v3, how to get contacts for a specific group?使用 Google Contacts API v3,如何获取特定群组的联系人?
【发布时间】:2015-08-10 20:52:43
【问题描述】:

我可以获取联系人和群组。我无法做的是查询特定组的联系人。我已经阅读了文档,并且指定组 Atom Id 没有意义,因为存在类型冲突。

const string name = "MyGroup";
var uri = ContactsQuery.CreateGroupsUri("default");
var gQuery = new GroupsQuery(uri);
var group = cr.Get<Group>(gQuery).Entries.AsQueryable()
    .SingleOrDefault(e => e.GroupEntry.Title.Text.Contains(name));

uri = ContactsQuery.CreateContactsUri("default");
var cQuery = new ContactsQuery(uri);
if (group != null)
{
   cQuery.Group = (string)group.AtomEntry.Id;   //  WHAT TO PUT HERE ?
}
Feed<Contact> feed = cr.Get<Contact>(cQuery);

无法分配类型 AtomId...

group.AtomEntry.Id // type = AtomId

... 为 ... 转为字符串类型

cQuery.group // type = string

谢谢!

【问题讨论】:

    标签: c# .net google-api google-contacts-api


    【解决方案1】:

    改变...

    cQuery.Group = (string)group.AtomEntry.Id;
    

    到...

    cQuery.Group = (string)group.Id;
    

    提示来自this post。我意识到正在构建的 URI 很长,并且包括 [联系人 URI] + ?group= [组基/id URI]。示例:https://www.google.com/m8/feeds/contacts/default/full?group=http://www.google.com/m8/feeds/groups/user.email%40domain.com/base/some_alphanumeric_id

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-25
      • 1970-01-01
      • 1970-01-01
      • 2016-01-19
      • 1970-01-01
      • 2022-01-07
      • 1970-01-01
      相关资源
      最近更新 更多