« On Voting | Main | About a Girl (, Wearing Glasses) »

Post Skype's Mood Text to Twitter

I wrote a WSH script, skype2twitter.js, which allows you to post your mood text set on Skype client to Twitter. After setting your username and password of Twiter, just run it. Then, the script checks your mood text, and posts it to Twitter if changed.

Be sure that now it just only posts the mood text to twitter, that is, it doesn't synchronize the mood text and the status on Twitter, which can be updated from Web, IM or the other various places. I expect someone to enhance it to enable to do it.

To tell the truth, what I did with the script is just to mix this script and another one. Thank to them!

skype2twitter.js

// configurations
var username = 'username';
var password = 'password';
var interval = 60000;

var status;
var skype = newComObject("Skype4Com.Skype");
var ua    = createUserAgent();

while (true) {
    if (status == skype.CurrentUserProfile.MoodText) continue;

    status = skype.CurrentUserProfile.MoodText
    postStatus(ua, username, password, status);
    WScript.Sleep(interval);
}

function postStatus (ua, username, password, status) {
    try {
        ua.open(
            'POST',
            'http://twitter.com/statuses/update.json',
            false,
            username,
            password
        );
        ua.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        ua.setRequestHeader('X-Twitter-Client', 'Skype2Twitter');
        ua.setRequestHeader('X-Twitter-Client-Version', '0.01');
        ua.setRequestHeader('X-Twitter-Client-URL',  'http://blog.kentarok.org/2007/04/10/skype2twitter.xml');
        ua.send('status=' + encodeURIComponent(status));

        if(ua.status == 200) {
            print('Updated: ' + status);
        }
        else {
            print('Error: ' + ua.status + ' - ' + ua.statusText);
        }
    }
    catch (e) {
        print (e.message);
    }
}

function createUserAgent () {
    try{
        return new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch (e) {
        try{
            return new ActiveXObject('Microsoft.XMLHTTP');
        }
        catch(e){
            return null;
        }
    }
}

function newComObject (lib) {
    var obj;

    try {
        obj = WScript.CreateObject(lib);
    }
    catch(e){
        obj = new ActiveXObject(lib);
    }

    return obj;
}

function print (string) {
    WScript.Echo(string);
}

TrackBack

Listed below are links to weblogs that reference Post Skype's Mood Text to Twitter:

» SkypeとTwitter from Web屋さんのココロえ
面白そうなので超特急で自分のblogにSkypeとTwitterのステータスを出 [Read More]

Comments (2)

Hi, I just made some improvement on your code to change it from periodical checking to processing mood message update event. I named it smitter - Skype Mood Message to Twitter. Take a look at http://hi.baidu.com/tvbinstinct/blog/item/b374f0deef16ae5694ee37a4.html if you want. Thank you for your work.

Great! It looks definitely nicer than mine. I hope it would become easier to post mood texts to Twitter by Twitter's supporting Skype.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on April 10, 2007 8:23 PM.

The previous post in this blog was On Voting.

The next post in this blog is About a Girl (, Wearing Glasses).

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34