Welcome to twitter
When I signed in this morning Micha greets me with his status of eliminating the first pot of coffee. Very interesting… So we decided to start twittering ;)
I already registered an account about ten months ago, just to see how it works, but now I’ll try to show some activity and tweet a lot of boring things..
First of all I developed a little script that tweets my messaged via curl:
#!/bin/bash
user=USER
msg=$*
if [ "${#msg}" -gt 140 ]
then
echo "msg too long: ${#msg}"
exit 1
fi
curl --basic -u $user -d status="$msg" https://twitter.com/statuses/update.xml >> /dev/null
Just call it with your message, it will ask for a passphrase to your account.. Just download it and use it like ./tweet.sh yeah it works
.
And of course I’ve written a script that dumps all news to my console. To parse the XML I’m using Perl:
#!/usr/bin/perl -w
use warnings;
use strict;
use LWP::UserAgent;
use XML::TreeBuilder;
use XML::Entities;
use POSIX;
binmode STDOUT, ":utf8";
my $max = 10;
$max = $ARGV[0] if ($ARGV[0] && isdigit ($ARGV[0]));
my $browser = LWP::UserAgent->new;
$browser->credentials('twitter.com:443', 'Twitter API', 'USER' => 'PASSWORD' );
my $response = $browser->get('https://twitter.com/statuses/friends_timeline.xml');
die "failed...\\n" . $response->status_line if (!$response->is_success);
my $tree = XML::TreeBuilder->new();
$tree->parse($response->decoded_content);
my $anz = 1;
foreach my $status ($tree->find_by_tag_name ('status'))
{
my $time = XML::Entities::decode ('all', $status->find_by_tag_name ('created_at')->as_text);
my $text = XML::Entities::decode ('all', $status->find_by_tag_name ('text')->as_text);
my $user = XML::Entities::decode ('all', $status->find_by_tag_name ('user')->find_by_tag_name ('screen_name')->as_text);
print "$text\\n\\tby $user at $time\\n\\n";
last if (++$anz > $max);
}
A little bit more code, but easy to use! Just download and run it with ./twitstat.pl [MAX_NUMBER_OF_TWEETS]
. (You may need some additional Perl libs)
So let’s see how long I keep going on.. You can follow me at http://twitter.com/binfalse
Leave a comment
There are multiple options to leave a comment:
- send me an email
- submit a comment through the feedback page (anonymously via TOR)
- Fork this repo at GitHub, add your comment to the _data/comments directory and send me a pull request
- Fill the following form and Staticman will automagically create a pull request for you:
1 comment
Twitter disabled Basic Authentication…
Some of you may have recognized that twitter has disabled the so called Basic Authentication. So my previous twitter-tools don’t work anymore. But don’t bury your head in the sand, here are the newer versions…….