Get Google contacts via AuthSub c#

有些话、适合烂在心里 提交于 2019-12-13 05:24:29

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5678038/get-google-contacts-via-authsub-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!