Printer Friendly Version      Send     
Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Windows Live
 Inviting Users to Share Online Pres...
Windows Live
Inviting Users to Share Online Presence

You can invite users to provide permission to display their online presence. This is done by adding a link to the signup page. When a user clicks the signup link, the user is taken to a Windows Live Messenger settings page. Once signup is complete the user is directed back to the URL that you specified in the signup link. You can then use the user's ID to query for the user’s online presence.

To invite users to provide permission to share their online presence, create a link to the following url using the following syntax:

http://settings.messenger.live.com/applications/websignup.aspx?returnurl=[URL]&privacyurl=[URL]

where returnurl is the URL on your site that the user will be returned to, and privacyurl is the URL for your site's privacy page. You must provide a privacy policy for your site in order to use this service.

For example:

http://settings.messenger.live.com/applications/websignup.aspx?returnurl=http://example.com/return.aspx&privacyurl=http://example.com/privacy.htm

When signup is complete, the signup page then calls the return URL, supplying the user's ID and the result status as parameters as shown in the following example:

http://example.com/return.aspx?Result=Accepted&id=12BACD345678@apps.messenger.live.com

This ID can be used with both the Windows Live Presence API and the Windows Live Messenger IM Control.

The following table shows the return URL parameters.

Parameter Value Example

Id

ID of the user that opted in. This is only sent if the return result is Accepted.

12BACD345678@apps.messenger.live.com

Result

One of the following:

Accepted

Declined

NoPrivacyUrl

Accepted

Note:
Users can also provide permission manually by going to http://settings.messenger.live.com/applications/websettings.aspx.

The following code example shows a simple code-behind page that parses the response URL, and displays the results.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.SessionState;
using System.Text.RegularExpressions;
using System.Collections.Specialized;
public partial class _Default : System.Web.UI.Page 
{
   string result = "";
   string userId = "";
   protected void Page_Load(object sender, EventArgs e)
   {
      if (!IsPostBack)
      {
         // Go through and extract the returned QueryString values.
         NameValueCollection returnParams = Request.QueryString;

         for (int i = 0; i < returnParams.AllKeys.Length; i++)
         {
            String nextKey = returnParams.AllKeys[i];
            if (nextKey == "result")
               result = returnParams[i];
            else if (nextKey == "id")
               userId = returnParams[i];
         }
         // If the result is success, save values to session.
         if ((result == "Accepted") && (userId != null))
         {
            // Save result data to the session.
            Session["Result"] = result;
            Session["Id"] = userId;
            
            // Display the result data.
            lblReturn.Text = "Result: " + result + ", User ID: " + userId;
         }
         // If the result does not succeed, display an error.
         else if (result != "Accepted")
         {
            if (result == "Declined")
               lblReturn.Text = "[" + result + "]" + " User permissions were declined.";
            else if (result == "NoPrivacyUrl")
               lblReturn.Text = "[" + result + "]" + " No privacy URL was supplied.";
         }
      }
   }
}
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker