Export (0) Print
Expand All

Contact Class

Ff750578.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.

An instance of the LiveItem class that provides programmatic access to a Windows Live contact.

Script:  http://js.live.net/4.1/loader.js
Feature:  Microsoft.Live.Services
Namespace:  Microsoft.Live.Services
 
Ff750578.alert_note(en-us,MSDN.10).gifNote

The JavaScript Library for Windows Live Messenger Connect is built by using the Microsoft Ajax Library. Microsoft Ajax exposes a type system that enables you to add object-oriented capabilities to your JavaScript code. To learn more about creating, instantiating, and deriving from classes, see Creating Custom Client Script by Using the Microsoft Ajax Library.

Microsoft.Live.Services.Contact = function();

Type.registerClass(
    'Microsoft.Live.Services.Contact',
    Microsoft.Live.Services.Resource);

A contact is a top-level resource type that is accessible in Windows Live Services. The resource type encapsulates information about a contact that might appear in a user's address book or information about a contact in a social network. The Contact class represents a programmatic view of a contact that provides methods to get and set properties of a contact and supports monitoring change events and saving changes to the contact. For more information on the resource contact, see Windows Live Resource Model.

When you request contacts for an authenticated user from Windows Live, you receive an instance of the ContactCollection class, which is a collection of Contact objects.

The following example demonstrates how to get an instance of the DataContext class from the dataContext property of the App class and create a ContactCollection object. The code iterates through the Contact objects in the collection.

To call the appLoaded function, specify the function name in the onload property of the App Control or in the initialize method of the App object.

function contactsLoaded(dataLoadCompletedEventArgs) {
    if (dataLoadCompletedEventArgs.get_resultCode() !== wl.AsyncResultCode.success) {
        alert("Contacts failed to load.");
        return;
    }
    var sb;
    sb = "";
    contactsCollection = dataLoadCompletedEventArgs.get_data();
    for (var i = 0; i < contactsCollection.get_length(); i++) {
        var contact = contactsCollection.getItem(i);
        sb += contact.get_firstName() + ", " + contact.get_lastName() + "<br/>";
    }
    var elem = $get("Output");
    elem.innerHTML = sb;
}
function signin() {
    Microsoft.Live.App.signIn(signInComplete);
}
function signInComplete(signInCompletedEventArgs) {
    if (signInCompletedEventArgs.get_resultCode() !== wl.AsyncResultCode.success) {
        alert("Signin failed.");
        return;
    }
    else {
        datacontext = Microsoft.Live.App.get_dataContext();
        datacontext.loadAll(Microsoft.Live.DataType.contacts, contactsLoaded);
    }
}

Object
  SubscribableBase
    Microsoft.Live.Services..::.LiveItem
      Microsoft.Live.Services..::.Resource
        Microsoft.Live.Services..::.Contact

Windows Live Messenger Connect

Supported in: 4.1

Internet Explorer 8.0, Internet Explorer 7.0, Internet Explorer 6.0, Firefox 3.6, Firefox 3.5, Firefox 3.0, Firefox 2.0, Firefox 1.5, Chrome 4.0, Chrome 3.0, Chrome 2.0, Chrome 1.0, Safari 4.0, Safari 3.0

Show:
© 2014 Microsoft