通过 AuthSub c# 获取 Google 联系人

发布于 2024-11-02 06:08:05 字数 193 浏览 1 评论 0原文

有没有人有一个在 c# 中通过 AuthSub 获取谷歌联系的工作示例

我已经尝试过这个 url ,但我无法完成它。

Does any one have a working example of getting google contact via AuthSub in c#

I have tried this url , but i was not able to complete it.

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

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

发布评论

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

评论(2

雪若未夕 2024-11-09 06:08:05

这是我的一个项目中的一段代码:

    public class GoogleContactsProvider : IContactProvider
{
    #region IContactProvider Members

    /// <summary>
    /// Gets the contacts list form the contact provider.
    /// </summary>
    /// <returns></returns>
    public EntityCollection<IContactItem> GetContactsList()
    {
        EntityCollection<IContactItem> collection = new EntityCollection<IContactItem>();

        // Setup the contacts request (autopage true returns all contacts)
        RequestSettings requestSettings = new RequestSettings("AgileMe", UserName, Password);
        requestSettings.AutoPaging = true;
        ContactsRequest contactsRequest = new ContactsRequest(requestSettings);

        // Get the feed
        Feed<Contact> feed = contactsRequest.GetContacts();

        // create our collection by looping through the feed
        foreach (Contact contact in feed.Entries)
        {
            GoogleContactItem newContact = new GoogleContactItem();
            newContact.Name = contact.PrimaryEmail.Address;
            newContact.Summary = contact.Summary;

            collection.Add(newContact);
        }

        return collection;
    }

    /// <summary>
    /// Gets or sets the name of the user for the contact provider.
    /// </summary>
    /// <value>The name of the user.</value>
    public string UserName { get; set; }

    /// <summary>
    /// Gets or sets the password for the contact provider.
    /// </summary>
    /// <value>The password.</value>
    public string Password { get; set; }

    #endregion
}

EntityCollection 是一个简单列表的包装器,GoogleContactItem 是一个检索到的信息的包装器。

Here is a piece of code from one of my projects:

    public class GoogleContactsProvider : IContactProvider
{
    #region IContactProvider Members

    /// <summary>
    /// Gets the contacts list form the contact provider.
    /// </summary>
    /// <returns></returns>
    public EntityCollection<IContactItem> GetContactsList()
    {
        EntityCollection<IContactItem> collection = new EntityCollection<IContactItem>();

        // Setup the contacts request (autopage true returns all contacts)
        RequestSettings requestSettings = new RequestSettings("AgileMe", UserName, Password);
        requestSettings.AutoPaging = true;
        ContactsRequest contactsRequest = new ContactsRequest(requestSettings);

        // Get the feed
        Feed<Contact> feed = contactsRequest.GetContacts();

        // create our collection by looping through the feed
        foreach (Contact contact in feed.Entries)
        {
            GoogleContactItem newContact = new GoogleContactItem();
            newContact.Name = contact.PrimaryEmail.Address;
            newContact.Summary = contact.Summary;

            collection.Add(newContact);
        }

        return collection;
    }

    /// <summary>
    /// Gets or sets the name of the user for the contact provider.
    /// </summary>
    /// <value>The name of the user.</value>
    public string UserName { get; set; }

    /// <summary>
    /// Gets or sets the password for the contact provider.
    /// </summary>
    /// <value>The password.</value>
    public string Password { get; set; }

    #endregion
}

EntityCollection is a wrapper around a simple List and GoogleContactItem is a wrapper around the retrieved information.

梨涡少年 2024-11-09 06:08:05

我发现这个例子很简单。 链接
而且效果很好。

I found this example so simple. link
And it works great.

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