2008年7月2日水曜日

TwitterのつぶやきをMSNメッセンジャーに反映させる

1. Messenger Plus! Live をインストールする
http://www.msgpluslive.net/

2. rss2psm Nutz をインストールして、TwitterのRSSを登録する
Messenger Plus! Live - Script - rss2psm Nutz

3. そのままだとTwitterのユーザ名が表示されたり、@付きのメッセージも表示されて具合が悪いので、rss2psm Nutzを編集する。

feedReeding.js の getFirstPosts() を編集する
(※青字のコードを追加)

// 4. Gets the Title and Link fields from the first item in the xml tree
function getFirstPosts(postNode)
{
var readTitle = postNode.getElementsByTagName("title");
var readLink = postNode.getElementsByTagName("link");

if ( readTitle.length > 0 ) postTitle = readTitle[0].firstChild.nodeValue;

// check @ post
var atMarkIndex = postTitle.indexOf("@");
if ( atMarkIndex >=0 ) return;

// formatting message
var colonIndex = postTitle.indexOf(" ")+1;
postTitle = postTitle.substr(colonIndex);


// If the link node has childs, then its a RSS feed, if not, then its an ATOM feed
if ( readLink.length > 0 )
{
if ( readLink[0].childNodes.length > 0 ) {
postLink = readLink[0].firstChild.nodeValue;
postContent = postNode.getElementsByTagName("description")[0].firstChild.nodeValue;
} else {
postLink = getAtomLink(readLink);
postContent = postNode.getElementsByTagName("content")[0].firstChild.nodeValue;
}
}

Debug.Trace(" Title: " + postTitle);
Debug.Trace(" Link: " + postLink);
Debug.Trace(" Content: " + postContent);

checkEmpty(postTitle);
checkEmpty(postLink);
checkEmpty(postContent);

updatePSM()
}

0 件のコメント: