Subscribe to our RSS Feeds

Welcome to Home of Microsoft Updates and News!

Do you want all updates from Microsoft, MSN, and Windows? this is your blog. We gathered all posts from original sources for you in one place!

CREATING DESKTOP APPLICATIONS WITH MESSENGER CONNECT

Add comments

Recently, we expelled chronicle 4.1 of Windows Live Messenger Connect. This chronicle brings Messenger Connect out of beta as well as creates it accessible to everyone. Angus Logan describes many of the changes we’ve done in his brand brand new blog post. we additionally rarely suggest we check out the brand brand new developer guide, which outlines how we can proceed office office building applications which confederate with Windows Live.

A usual subject which we’ve been asked has been upon office office building desktop applications with Messenger Connect. While it’s loyal which many of the Messenger Connect support focuses upon web-based applications, we can still set up applications for the desktop regulating Messenger Connect. All we need is the Messenger Connect Desktop Starter Kit, now accessible for download from the MSDN Code Gallery. (Look for the record declared Desktop_Sample_App.zip underneath the v4.1 samples release.)

Before we proceed regulating the starter kit, we need to register your focus during http://manage.dev.live.com. Registration takes only the integrate of minutes; we can find some-more minute stairs upon the registration routine in the Messenger Connect documentation.

When we open the starter kit, you’ll find the integrate of opposite representation projects. The many appropriate the single to proceed with is the AuthTest project. This plan provides the elementary pass in to how to make make use of of the Messenger Connect authentication as well as agree process. For this plan to accumulate as well as run correctly, open the SigninTester.cs record in the AuthTest Project. Then, fix up the line:

AppInformation appInfo = new AppInformation("00000000YourClientID", "YourSecretKey", requestedScopes);

Change the values in line to enclose the customer ID as well as tip pass we perceived when we purebred your application.

When we accumulate as well as run the sample, we get the flattering elementary dialog box.

Nothing as well exciting, yet. But notice the http://apis.live.net/V4.1 endpoint in the content box – some-more upon which shortly. First, let’s get things starting by clicking the SignIn button. This brings up the Windows Live agree dialog box.

 

Type in the current Windows Live ID as well as password, as well as afterwards click Connect. Back in the representation application, the SignIn symbol has altered to the Navigate button. Click the button, as well as the dialog updates with the top-level REST interpretation located during http://apis.live.net/V4.1.

 

From here, we can navigate by the REST endpoints by duplicating as well as pasting them in to the URI content box. For example, if we wish to get my form information, we would make make use of of http://profiles.apis.live.net/v4.0/cid-XXX/Profiles, where XXX is the CID the focus perceived after we sealed in.

 

You can get the unequivocally great clarity of how the REST endpoints work in Messenger Connect regulating the REST Explorer: http://rex.mslivelabs.com/.

So what’s starting at the behind of the scenes here? Let’s tighten out of the dialog box as well as lapse to Visual Studio. Open up the SignInTester.cs file. This is the record that’s we do many of the work. Two methods mount out in particular: SigninSynchronous as well as btnNavigate_Click.

 void SigninSynchronous()

{

user1 = new MessengerConnectSigninContext();

Collection<Scope> requestedScopes = new Collection<Scope>();

requestedScopes.Add(Scope.ContactsView);

AppInformation appInfo = new AppInformation("00000000YourClientID", "YourSecretKey", requestedScopes);

user1.GetToken(appInfo);

EnableMessengerConnectBrowsing();

}

The SigninSynchronous process fires when the user clicks the Signin button. The unequivocally engaging partial here is the scopes collection:

 Collection<Scope> requestedScopes = new Collection<Scope>();

This line creates it easy to supplement the scopes which carry out what Windows Live interpretation we can entrance upon the user’s behalf. In the starter kit, we’re removing the WL_Contacts.View range from the pre-defined constant, as shown in the line:

requestedScopes.Add(Scope.ContactsView);

If we longed for to ask one some-more scopes, we’d only need to call requestedScopes.Add again for any one some-more scope. Check out the SDK for some-more report upon what scopes have been available, as well as what they do.

Once we have the scopes we want, it’s only the make the difference of formulating the brand brand new AppInformation intent which contains your application’s customer ID, tip key, as well as requested scopes. The GetToken process handles opening the Windows Live Consent dialog box as well as estimate the entrance token we get behind when the user signs in successfully.

The btnNavigate_Click process is really identical to what we would do if we were essay the web application.

private void btnNavigate_Click(object sender, EventArgs e)

{

 

    try

    {

        Uri someUri = new Uri(txtUri.Text);

        WebRequest webRequest = HttpWebRequest.Create(someUri);

        webRequest.Method = "GET";

        webRequest.Headers[MessengerConnectConstants.AuthorizationHeader] = user1.AuthorizationToken;

        WebResponse webResponse = webRequest.GetResponse();

 

 

        StreamReader responseStreamReader = new StreamReader(webResponse.GetResponseStream());

 

        String reply = responseStreamReader.ReadToEnd();

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(response);

        StringBuilder formattedBuilder = new StringBuilder();

        XmlWriterSettings settings = new XmlWriterSettings();

        settings.Indent = true;

        XmlWriter bard = XmlWriter.Create(formattedBuilder, settings);

        doc.WriteTo(writer);

        writer.Close();

 

        txtOutput.Text = formattedBuilder.ToString();

    }

    catch (Exception exception)

    {

        txtOutput.Text = exception.Message + "\r\n" + exception.StackTrace;

    }

}

As we can see, it takes the URI as well as creates the WebRequest regulating the entrance token of the Windows Live user. As this is the flattering elementary example, the process only writes the reply behind out to the dialog box. This is where we can precedence the REST Explorer as well as the Windows Live SDK to set up some-more functionality in to the sample.

We goal this starter pack gives we the little great discernment upon how to set up desktop applications with Messenger Connect. We’re operative tough upon upon condition that some-more report upon how to formula with Messenger Connect – meanwhile, if we have questions or feedback, greatfully leave the comment.

Windows Live Services October 15th 2010

Leave a Reply

Spam Protection by WP-SpamFree