MSN API 網頁應用

參考文件
http://msdn.microsoft.com/en-us/library/bb936688.aspx

其他更多文件:
http://dev.live.com/Messenger/default.aspx

語法:

http://messenger.services.live.com/users/[ID]/[resource]/[?queryparameters]

The [ID] is of format id@apps.messenger.live.com

The [resource] is either:

* presence: For presence JSON or JavaScript
* presenceimage: for an image icon denoting the user’s presence


範例 (使用 jQuery.getJSON)

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Display MSN status</title>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
</head>
<body>
<script type="'text/javascript'">
$(window).load(function() {
$.getJSON('http://messenger.services.live.com/users/你的帳號/presence/?cb=?', function(data) {
var items = [];

$.each(data, function(key, val) {
items.push('<li id="' + key + '">' + val + '</li>');
});

$('<ul/>', {
'class': 'my-new-list',
html: items.join('')
}).appendTo('body');
});
});
</script>
</body>
</html>

範例 (使用 ASP XMLHTTP3.0)

<%
Response.Write Replace(GetHTML("http://messenger.services.live.com/users/你的帳號/presence/"), ",", "<br />")

Function Bin2Str(Bin)
Dim xI, Str, clow
For xI=1 to LenB(Bin)
clow=MidB(Bin,xI,1)
if ASCB(clow)<128 then
Str = Str & Chr(ASCB(clow))
else
xI=xI+1
if xI <= LenB(Bin) then Str = Str & Chr(ASCW(MidB(Bin,xI,1)&clow))
end if
Next
Bin2Str = Str
End Function

Function GetHTML(strURL)
Dim objXMLHTTP, strReturn
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
objXMLHTTP.Open "GET", strURL, False
objXMLHTTP.Send
strReturn =objXMLHTTP.responseBody
Set objXMLHTTP = Nothing
strReturn=bin2str(strReturn)
GetHTML = strReturn
End Function
%>

Share this

Related Posts

Previous
Next Post »