0

试图检索单个联系人。在链接中,它说:

public static Contact retrieveContact(ContactsRequest cr)
{
  Contact contact = cr.Retrieve<Contact>("https://www.google.com/m8/feeds/contacts/default/full/contactId");
  return contact;
}

怎么知道联系人的自链接 URL,甚至是contactId?我尝试了不同的变体:

https://www.google.com/m8/feeds/contacts/default/full/firstname.lastname https://www.google.com/m8/feeds/contacts/ourdomain.com/full/firstname.lastname https: //www.google.com/m8/feeds/contacts/firstname.lastname%40ourdomain.com/full/firstname.lastname

但我似乎无法获得正确的返回值。我得到的只是未找到异常。

完整的错误信息是:

{“远程服务器返回错误:(404)未找到。”}

我能够连接到该服务,因为如果我检索所有联系人,我就可以进行适当的查询。但是在检索单个联系人时有点难过。

有人已经在这方面工作了吗?

感谢任何建议。

更新:例如,如果您使用 ContactsQuery,例如:

    ContactsQuery query =
                    new ContactsQuery("https://www.google.com/m8/feeds/profiles/domain/" + this.domain + "/full");
query.Query = ?????

我们可以在查询对象中指定什么以便我们实际上只检索一个用户(基于用户名或电子邮件地址)?

更新:我使用 GAM ( https://code.google.com/p/google-apps-manager/ ) 来检索特定用户,那里有一个由一堆数字组成的 ID 字段。我尝试使用它来代替上面 URI 中的 ContactID 字段,但所有变体都只返回 403 Not Found 错误。

4

3 回答 3

1
 public Contact GetContact(ContactsRequest cr, string email)
    {
        string qstring = "https://www.google.com/m8/feeds/contacts/default/full?q=" + email + "&v=3.0";
        Uri thisuri = new Uri(qstring);
        Contact contact = cr.Retrieve<Contact>(thisuri);
        return contact;
    }
于 2014-08-26T17:30:47.870 回答
0

你需要contactId提前知道。无法使用联系人 API 从他们的电子邮件地址中查找联系人记录。

如果您只是在您的域中寻找用户,请查看 Directory API - https://developers.google.com/admin-sdk/directory/v1/guides/manage-users#get_user

于 2013-11-04T20:51:01.113 回答
0

当您使用搜索时:www.google.com/m8/feeds/contacts/default/full?q=lastname+firstname+... 您可以将结果限制为您想要更新的内容。从“条目”结果中获取“id”时,您会注意到它的格式类似于“ http://www.google.com/m8/feeds/contacts/yourself%40gmail.com/base/7e ” id, 7e在这种情况下,是在“/base/”之后。

使用 www.google.com/m8/feeds/contacts/default/full/7e 时,您将获得所请求用户的条目。

您可以从https://developers.google.com/google-apps/contacts/v3/#retrieving_a_single_contact上的信息推断出这一点

于 2014-02-05T20:30:49.023 回答