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
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
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.