Wednesday, December 07, 2011

The Littlest Twitter Term Counter

A basic need of many folks I work with is to count hashtags or terms on Twitter in real time.

The below isn't a complete solution by any means but it does the job in the simplest sunny-day case. If you, or your technical team, are looking for the most basic starting point then this is it:

curl -d 'track=TERM' -uUSERNAME:PASSWORD -s -o - \
https://stream.twitter.com/1/statuses/filter.json \
| perl -e '$|++; while (<>) {m/\{/ and $i++ and print qq{\r$i}}'

Fill in the values in CAPS (use your Twitter credentials) and you're all set.