Uncensored Twitter content will be viewed at the end and may contain offensive, racist, sexual terms etc.
as in, Twitter + App + Apophenia.
Apophenia:
The spontaneous perception of connections and meaningfulness in unrelated things.
William Gibson
1 technically this is not the firehose
Twitter will happily stream tweets to your application, (in JSON), forever.
No, seriously. That length of time again: “forever”.
To connect to the Streaming API, form an HTTP request and consume the resulting stream for as long as is practical. Our servers will hold the connection open indefinitely, barring server-side error, excessive client-side lag, network hiccups, routine server maintenance or duplicate logins.
Twitter Documentation
You can do this the hard way or the easy way...
I'm still not sure which one I chose.
I didn't use a module, and I didn't make the request in Perl...
I found some code to build the OAuth request header as a string…
and used curl to hit the stream…
I used curl because it has a cutoff argument which solves the "how to stop" problem.
system( "/usr/bin/curl --request 'GET' 'https://stream.twitter.com/1.1/statuses/sample.json' --max-time 240 --header 'Authorization: $header' > /var/tmp/$time.json\n" );
sub make_header { use Digest::SHA qw(hmac_sha1 hmac_sha1_base64); use URI::Escape; my $conf = shift; my $header = "OAuth "; my $nonce = time(); my $signature_method = "HMAC-SHA1"; my $version = "1.0"; my $http_method = "GET"; my $base_url = "https://stream.twitter.com/1.1/statuses/sample.json"; my $timestamp = time(); my $signature_base = uri_escape("oauth_consumer_key") . '=' . uri_escape( $conf->{consumer_key} ) . '&'; $signature_base .= uri_escape("oauth_nonce") . '=' . uri_escape($nonce) . '&'; $signature_base .= uri_escape("oauth_signature_method") . '=' . uri_escape($signature_method) . '&'; $signature_base .= uri_escape("oauth_timestamp") . '=' . uri_escape($timestamp) . '&'; $signature_base .= uri_escape("oauth_token") . '=' . uri_escape( $conf->{token} ) . '&'; $signature_base .= uri_escape("oauth_version") . '=' . uri_escape($version); $signature_base = $http_method . "&" . uri_escape($base_url) . "&" . uri_escape($signature_base); my $signing_key = uri_escape( $conf->{consumer_secret} ) . "&" . uri_escape( $conf->{oauth_token_secret} ); my $signature = hmac_sha1_base64( $signature_base, $signing_key ); # the signature length needs to be a multiple of 4 while ( length($signature) % 4 ){ $signature .= '='; } $header .= uri_escape("oauth_consumer_key") . '="' . uri_escape( $conf->{consumer_key} ) . '", '; $header .= uri_escape("oauth_nonce") . '="' . uri_escape($nonce) . '", '; $header .= uri_escape("oauth_signature") . '="' . uri_escape($signature) . '", '; $header .= uri_escape("oauth_signature_method") . '="' . uri_escape($signature_method) . '", '; $header .= uri_escape("oauth_timestamp") . '="' . uri_escape($timestamp) . '", '; $header .= uri_escape("oauth_token") . '="' . uri_escape( $conf->{token} ) . '", '; $header .= uri_escape("oauth_version") . '="' . uri_escape($version) . '"'; return $header; }
So, all that is wrapped up in a nice little perl script and run by cron.
I have eaten the plums that were in the icebox and which you were probably saving for breakfast Forgive me they were delicious so sweet and so cold
“This Is Just To Say” (William Carlos Williams, 1883–1963)
They must be fourteen lines
There must be 10 syllables in each line
They should rhyme in the following pattern:
a b a b c d c d e f e f g g
Shall I compare thee to a summer’s day? Thou art more lovely and more temperate. Rough winds do shake the darling buds of May, And summer’s lease hath all too short a date. Sometime too hot the eye of heaven shines, And often is his gold complexion dimmed; And every fair from fair sometime declines, By chance, or nature’s changing course, untrimmed; But thy eternal summer shall not fade, Nor lose possession of that fair thou ow’st, Nor shall death brag thou wand’rest in his shade, When in eternal lines to Time thou grow’st. So long as men can breathe, or eyes can see, So long lives this, and this gives life to thee.
Anyone know what that's all about?
We have Perl and jQuery…
So let's write a poem…
I will of course upload this slideshow later and provide code/links.
/