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
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.