Export (0) Print
Expand All

Working with Contacts (JavaScript Library)

Ff751887.note(en-us,MSDN.10).gifNote:
Current information about Live Connect is now available in the Windows Live Developer Center. The information in the following sections is provided for legacy purposes only.

A contact is a top-level resource type that encapsulates information about a contact. Windows Live users can organize contacts into categories, and a contact can belong to zero or many categories.

By using Windows Live Messenger Connect, you can access a Windows Live user's contacts and categories, but only after the user is authenticated and provides consent. You can reference Windows Live contacts either as a collection or individually. Specifically, when a user signs in and gives consent, your web application can request the user's contacts by using a data context. For more information, see Using the Data Context.

Working with a Contact Collection

By using the data context, you retrieve a ContactCollection object. ContactCollection contains items of the Contact class.

A Contact object is a programmatic representation of a contact and provides:

  • Methods to get properties of the contact.
  • Support for monitoring change events of the contact.

For more information about the resource contact, see REST API Service and Resource Model (Messenger Connect).

After you retrieve a contact collection, the granted scope that was used to query the collection determines what operations you can perform with the contacts. For more information about scopes, see Messenger Connect Scopes. For more information about working with the data context, see Using the Data Context.

The following topics demonstrate different operations on contacts.

Topic Description

Working with Contacts (JavaScript Sample)

Demonstrates how to work with contacts and categories and how to display which categories a contact belongs to

Enumerating Contacts

Demonstrates how to display basic contact information

Working with a Large Contact Collection

When you request contacts for an authenticated user, consider the following points:

  • The Windows Live endpoint returns a maximum of 100 contacts. If you use the loadAll method of the DataContext class only once, and if more than 100 contacts exist, you will not load all of the contacts.
  • For large contact collections, you should consider a recursive load approach. For more information, see Working with Large Contact Collections.
  • Whenever possible, load only what is needed. You can use the load method of DataContext to specify filter arguments.
  • Consider creating a view of user contacts. Represented programmatically by the View object, a view provides paging and filtering functions. A view responds to requests for more data as the user scrolls through his or her contacts. For an example of how to use a view, see Enumerating Contacts by Using a View.

Working with a Category

You work with categories in the same way that you work with contacts. You can also add or remove contacts from a category.

From the data context, you can retrieve a ContactCategoryCollection object that contains ContactCategory items. The ContactCategory class represents a programmatic view of a category. It provides:

  • Methods to get and set properties of a category.
  • Support for monitoring change events and saving changes to the category.

You can query the contacts in a category by using the Microsoft.Live.Services.ContactCategory.contacts property.

The following topics demonstrate different operations on contacts.

Topic Description

Working with Categories

Demonstrates how to get the categories of an authenticated user and how to display the properties of each category

Working with Contacts (JavaScript Sample)

Demonstrates how to work with contacts and categories and how to display which categories a contact belongs to

Show:
© 2014 Microsoft