"IM this": Instant Message this or that through MSN / Windows Live Messenger
2009-01-16 11:42
519 查看
If you want to put that cool feature available @ http://msnbc.msn.com (click here for an example) which you can share some content with any or all of your contacts in Messenger, read this!
They call it "launching an activity", the original documentation you can find here.
File "MSGRP2P.xml"
<?xml version="1.0"?>
<Entry>
<EntryID>7</EntryID>
<Error />
<Locale>pt-br</Locale>
<Kids>0</Kids>
<Page>1</Page>
<Category>50</Category>
<Sequence>10</Sequence>
<Name>Oh boy! On ASP.NET</Name>
<Description>Share content through MSN</Description>
<URL>http://your_machine_name_or_host/Application/ViewContent.aspx</URL>
<IconURL />
<PassportSiteID>0</PassportSiteID>
<Type>App</Type>
<Height>500</Height>
<Width>500</Width>
<Location>side</Location>
<MinUsers>2</MinUsers>
<MaxUsers>2</MaxUsers>
<PassportSiteID>0</PassportSiteID>
<EnableIP>False</EnableIP>
<ActiveX>False</ActiveX>
<SendFile>False</SendFile>
<SendIM>False</SendIM>
<ReceiveIM>False</ReceiveIM>
<ReplaceIM>False</ReplaceIM>
<Windows>False</Windows>
<MaxPacketRate>120</MaxPacketRate>
<UserProperties>False</UserProperties>
<ClientVersion></ClientVersion>
<AppType>0</AppType>
<Hidden>false</Hidden>
</Entry>
This is the configuration file of your activity. To actually share content in a production enviroment you need to register your activity in Windows Live Gallery. If you want the same feature as MSNBC web site, you should get the MSGRP2P.xml file above and just change the Locale, Name, Description and URL nodes. Detailed explanation of each node can be found at http://msdn2.microsoft.com/en-us/library/aa751073.aspx.
Just AFTER your Activity be approved by Microsoft you will receive a production Application ID and you may test it integrated with the browser, before that, you need to place this XML in the same directory MSN executable file is and send the SAME XML file to somebody else who is going to test the activity with you. Place the XML file in the same directory MSN executable is too.
File "Default.aspx"
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MSN</title>
<script type="text/javascript" language="javascript">
function IMThis(contentID)
{
try
{
var obj = new ActiveXObject("MSNMessenger.P4QuickLaunch");
}
catch(e)
{
obj=null;
};
if(obj!=null)
{
SaveCookie('CONTENTID', contentID, 10);//cookie will expire in 10 days
//obj.LaunchApp('7', '');
}
else
{
alert('User does not have MSN installed or is using Firefox.');
}
}
function SaveCookie(name, value, expirationTime)
{
var expirationDate=new Date();
expirationDate.setDate(expirationDate.getDate()+expirationTime);
document.cookie = name + "=" + escape(value) + ((expirationTime==null) ? "" : "; expires="+expirationDate.toGMTString());
}
</script>
</head>
<body>
<form id="frmDefault" runat="server">
<h1>Contents</h1>
<h2>Some content 1</h2><a href="javascript: IMThis('1');" title="Send content 1 using MSN">Send by MSN</a>
<h2>Some content 2</h2><a href="javascript: IMThis('2');" title="Send content 2 using MSN">send by MSN</a>
<h2>Some content 3</h2><a href="javascript: IMThis('3');" title="Send content 3 using MSN">send by MSN</a>
</form>
</body>
</html>
We got a table of contents inside the form which simulates the contents people who visit your site is going to share with their contacts.
The "IMThis" function receives the content ID, try to launch MSN (Obviously won't work for who doesn't have MSN installed) and stores the content ID in a cookie through the SaveCookie function.
After you receive your production application ID from Microsoft, you may uncomment the line "obj.LaunchApp('7', '')" and replace '7', which is a test id with the application id you received from http://gallery.live.com.
File "ViewContent.aspx"
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/C#" runat="server">
void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
HttpCookie contentID = Request.Cookies["CONTENTID"];
this.FindControl(String.Format("div{0}", contentID.Value.ToString())).Visible = true;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>View Shared Content</title>
</head>
<body>
<h1>Content</h1>
<div id="div1" visible="false" runat="server">
<h2>Content ID: 1</h2>
</div>
<div id="div2" visible="false" runat="server">
<h2>Content ID: 2</h2>
</div>
<div id="div3" visible="false" runat="server">
<h2>Content ID: 3</h2>
</div>
</body>
</html>
This file just read the cookie saved by "Default.aspx" and displays the right content accordingly to the content id stored in the cookie.
How to test it
Send the URL you placed the Default.aspx file (something like http://yourmachinename/msn/default.aspx) to the contact you send the XML file, asks him/her to click in a "Send by MSN" link. After that, open the "Actions" menu, search for "Start [Name node in MSGRP2P.xml]" and waits to your test partner accepts the invitation. If he/she accepts the invitation, the Activity windows will open in the left of your and his/her conversation window redirected to the URL you supplied in the URL node of the MSGRP2P.xml file. The URL you supplied must be the file which reads the cookie and displays the right content. Got the magic?
I know this example is dumb but that's the most simple way I found to show people how to do it, any doubts, suggestion or anything else contact me please ;)
Sorry for the bad english and too long explanation/post, but I choose to detail it to the lower level to make it easir to understand since there is little to none documentation on this topic around the Internet.
Attention: Firefox don't support ActiveX objects or ActiveX can't support Firefox, so this feature won't work on Firefox. Opera would, though.
I wrote this article to reply Bilal's question at MSDN Forums. I hope it helps you Bilal ;)
Soundtrack to this post: Ja Rule feat. R. Kelly - Wonderful - yes I'm soft today ;)
They call it "launching an activity", the original documentation you can find here.
File "MSGRP2P.xml"
<?xml version="1.0"?>
<Entry>
<EntryID>7</EntryID>
<Error />
<Locale>pt-br</Locale>
<Kids>0</Kids>
<Page>1</Page>
<Category>50</Category>
<Sequence>10</Sequence>
<Name>Oh boy! On ASP.NET</Name>
<Description>Share content through MSN</Description>
<URL>http://your_machine_name_or_host/Application/ViewContent.aspx</URL>
<IconURL />
<PassportSiteID>0</PassportSiteID>
<Type>App</Type>
<Height>500</Height>
<Width>500</Width>
<Location>side</Location>
<MinUsers>2</MinUsers>
<MaxUsers>2</MaxUsers>
<PassportSiteID>0</PassportSiteID>
<EnableIP>False</EnableIP>
<ActiveX>False</ActiveX>
<SendFile>False</SendFile>
<SendIM>False</SendIM>
<ReceiveIM>False</ReceiveIM>
<ReplaceIM>False</ReplaceIM>
<Windows>False</Windows>
<MaxPacketRate>120</MaxPacketRate>
<UserProperties>False</UserProperties>
<ClientVersion></ClientVersion>
<AppType>0</AppType>
<Hidden>false</Hidden>
</Entry>
This is the configuration file of your activity. To actually share content in a production enviroment you need to register your activity in Windows Live Gallery. If you want the same feature as MSNBC web site, you should get the MSGRP2P.xml file above and just change the Locale, Name, Description and URL nodes. Detailed explanation of each node can be found at http://msdn2.microsoft.com/en-us/library/aa751073.aspx.
Just AFTER your Activity be approved by Microsoft you will receive a production Application ID and you may test it integrated with the browser, before that, you need to place this XML in the same directory MSN executable file is and send the SAME XML file to somebody else who is going to test the activity with you. Place the XML file in the same directory MSN executable is too.
File "Default.aspx"
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MSN</title>
<script type="text/javascript" language="javascript">
function IMThis(contentID)
{
try
{
var obj = new ActiveXObject("MSNMessenger.P4QuickLaunch");
}
catch(e)
{
obj=null;
};
if(obj!=null)
{
SaveCookie('CONTENTID', contentID, 10);//cookie will expire in 10 days
//obj.LaunchApp('7', '');
}
else
{
alert('User does not have MSN installed or is using Firefox.');
}
}
function SaveCookie(name, value, expirationTime)
{
var expirationDate=new Date();
expirationDate.setDate(expirationDate.getDate()+expirationTime);
document.cookie = name + "=" + escape(value) + ((expirationTime==null) ? "" : "; expires="+expirationDate.toGMTString());
}
</script>
</head>
<body>
<form id="frmDefault" runat="server">
<h1>Contents</h1>
<h2>Some content 1</h2><a href="javascript: IMThis('1');" title="Send content 1 using MSN">Send by MSN</a>
<h2>Some content 2</h2><a href="javascript: IMThis('2');" title="Send content 2 using MSN">send by MSN</a>
<h2>Some content 3</h2><a href="javascript: IMThis('3');" title="Send content 3 using MSN">send by MSN</a>
</form>
</body>
</html>
We got a table of contents inside the form which simulates the contents people who visit your site is going to share with their contacts.
The "IMThis" function receives the content ID, try to launch MSN (Obviously won't work for who doesn't have MSN installed) and stores the content ID in a cookie through the SaveCookie function.
After you receive your production application ID from Microsoft, you may uncomment the line "obj.LaunchApp('7', '')" and replace '7', which is a test id with the application id you received from http://gallery.live.com.
File "ViewContent.aspx"
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/C#" runat="server">
void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
HttpCookie contentID = Request.Cookies["CONTENTID"];
this.FindControl(String.Format("div{0}", contentID.Value.ToString())).Visible = true;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>View Shared Content</title>
</head>
<body>
<h1>Content</h1>
<div id="div1" visible="false" runat="server">
<h2>Content ID: 1</h2>
</div>
<div id="div2" visible="false" runat="server">
<h2>Content ID: 2</h2>
</div>
<div id="div3" visible="false" runat="server">
<h2>Content ID: 3</h2>
</div>
</body>
</html>
This file just read the cookie saved by "Default.aspx" and displays the right content accordingly to the content id stored in the cookie.
How to test it
Send the URL you placed the Default.aspx file (something like http://yourmachinename/msn/default.aspx) to the contact you send the XML file, asks him/her to click in a "Send by MSN" link. After that, open the "Actions" menu, search for "Start [Name node in MSGRP2P.xml]" and waits to your test partner accepts the invitation. If he/she accepts the invitation, the Activity windows will open in the left of your and his/her conversation window redirected to the URL you supplied in the URL node of the MSGRP2P.xml file. The URL you supplied must be the file which reads the cookie and displays the right content. Got the magic?
I know this example is dumb but that's the most simple way I found to show people how to do it, any doubts, suggestion or anything else contact me please ;)
Sorry for the bad english and too long explanation/post, but I choose to detail it to the lower level to make it easir to understand since there is little to none documentation on this topic around the Internet.
Attention: Firefox don't support ActiveX objects or ActiveX can't support Firefox, so this feature won't work on Firefox. Opera would, though.
I wrote this article to reply Bilal's question at MSDN Forums. I hope it helps you Bilal ;)
Soundtrack to this post: Ja Rule feat. R. Kelly - Wonderful - yes I'm soft today ;)
相关文章推荐
- Error message when you try to modify or to delete an alternate access mapping in Windows SharePoint Services 3.0: "An update conflict has occurred, and you must re-try this action"
- msn问题 windows live messenger已停止工作,出现了一个问题,导致程序停止正常工作
- You may receive an "Access Denied" or a "Permission Denied" scripting error message when you browse a secure Web site that contains multiple frames
- 如何解决 "This function or variable may be unsafe" 的问题
- 谁要windows live messenger(msn8.0)的邀请?
- This application failed to start because it could not find or load the Qt platform plugin "windows"
- Unable to parse template "Annotation" Error message: This template did not produce a Java class or a
- This application failed to start because it could not find or load the Qt platform plugin "windows"
- "Your computer could not be joined to the domain. You have exceeded the maximum number of computer accounts you are allowed to create in this domain. Contact your system administrator to have this limit reset or increased."
- MSN(Windows Live Messenger)即将正式寿终正寝
- DotMSN.dll 使用后 Windows Live Messenger 不能登录解决方案
- "无法解析的外部符号" 和 "This function or variable may be unsafe"
- This application failed start because it could not find or load the Qt platform plugin "windows in"
- FIX: Error message when you try to install a large Windows Installer package or a large Windows Installer patch package in Windows Server 2003 or in Windows XP: "Error 1718. File was rejected by digital signature policy"
- [Android App]IFCTT,即:If Copy Then That,一个基于IFTTT的"This"实现
- "it could not find or load the Qt platform plugin "windows""解决方法
- 实现了msnp(msn通信协议,windows live messenger用的通信协议)
- This application failed to start because it could not find or load the Qt platform plugin "windows"
- This application failed to start because it could not find or load the Qt platform plugin "windows"
- System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt".