Perl scripts send log messages to Twitter
Twittering for Geeks
The Twitter service can be a platform for meaningless chatter, or you can automate access with an API and use it in ways Twitter never envisioned.
Why on earth would anybody want to use a mobile phone to let the world know they are eating a pizza with friends, are down at the gym, or have just arrived somewhere by airplane?
Microblogging, as supported by Twitter or the free identi.ca variant, has some really amazing side effects. If you want to find out what the hottest issues are for humankind right at this moment, neither Google's search engine nor Wikipedia are likely to help. Take a look at the Twitter service front page (Figure 1) and you'll see people tweeting about local political upheavals, natural phenomena, the latest movie, or sports events – often long before the daily paper's editorial team or the TV channels have even noticed something is going on.
Fragile Giant
The fact that Twitter works at all is something close to a miracle. The service offers just minimal functionality, and its infrastructure is so fragile that breakdowns are just part of the daily grind. Yet 6 million users untiringly keep feeding the fragile beast news, continuously infuse new life in the form of brand new information, and thus have kept it alive and breathing since 2006. The Twitter team is reluctant to add new functionality; in fact, this typically only occurs when faithful Twitter fans have discovered hair-raising creative workarounds to eke new functions out of the gentle giant.
Twitter doesn't really offer much: Users with an account can send text messages of up to 140 characters to the service, which then publishes them, both on the Public Time Line and under the user's account. Combine this with a mobile phone and text or web capabilities, and you have a superficial but timely style of communication.
If you are interested in what another user has to say, you can register as a Follower of that user; this is like making somebody your buddy, and it automatically routes their message stream into your own. Commonly, users follow several other users; conversely, other users follow them. Imbalance is indicative of an issue; for example, spammers tend to follow many users, but nobody follows spammers or even likes to read their messages.
Although Twitter is free now, most likely they will apply the advertising thumbscrews at some stage, just to earn some money. The free identi.ca clone looks slightly different, but it gives you exactly the same functionality, including technical details like the URL layout (Figure 2). This means that you can point the Perl Net::Twitter module, for example, away from Twitter and at identi.ca by using a single parameter to replace http://twitter.com with http://identi.ca.
Just the Basics
Twitter's reluctance to introduce new features leads to people misusing the 140 characters available for each message as a kind of programming language to test new functions. "Retweets" – that is, messages that are worthy of being quoted and which followers of one Twitterer forward to their own followers – are one example of this. Because the original Twitter did not have this functionality, some clever users repeatedly added the RT @username string to their messages until Twitter finally gave way and recognized the "standard."
Twitter only gives you rough building blocks, and this is reflected in the lean API. All the more amazing, O'Reilly published a 400-page tome on the subject [2] describing the programming interface, including a short tutorial on web programming, and introducing a whole bunch of successful third-party Twitter applications.
Wiped Out
Although you could use the API to code another client with a GUI or text-based interface, it's also useful for cleaning up Twitter errors. When I created the perlsnapshot test account, I must have pressed the wrong button, because all of a sudden, no fewer than 20 friends appeared, and interestingly I'd never heard of any of them before. Deleting them individually in my browser would have been a nightmare, but presto, I knocked out the script shown in Listing 1 in less than five minutes, and running it against the list of false friends wiped them out of my life forever.
Listing 1
unfollow-all
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.