Using bit.ly with MovableType


I've been using the mt-twitter plugin to automatically publish blog articles to Twitter. I find that I get more readers that way than RSS or my newsletter at this point. One problem is that you don't get any good stats that way. I've modified the mt-twitter plugin to use bit.ly now to solve that problem. With bit.ly you can click on the "info" link and get good stats about who clicked from where.

This is the code I added to the _update_twitter function:

 my $bitly = LWP::UserAgent->new;
 my $url_response = 
       $bitly->get("http://bit.ly/api?url=" . $obj->permalink);
 my $small_url;
 if($url_response->is_success) {
    $small_url = $url_response->content;
} else {
   $small_url = $obj->permalink;
}

Of course, you also have to change the line that creates the twitter message to use the new shortened URL ($small_url) instead of the permalink directly.


Please leave comments using the Hypothes.is sidebar.

Last modified: Thu Oct 10 12:47:18 2019.