0

C#でAuthSubを介してGoogleの連絡先を取得する実際の例はありますか

このURLを試しましたが、完了できませんでした。

4

2 に答える 2

0

この例はとても簡単だと思いました。リンク そしてそれはうまくいきます。

于 2011-04-22T15:07:45.963 に答える
0

これは、私のプロジェクトの 1 つからのコードの一部です。

    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 は単純な List のラッパーであり、GoogleContactItem は取得した情報のラッパーです。

于 2011-04-15T14:18:34.593 に答える