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
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.