block by joyrexus 8044084

Latest tweets

Get the latest tweets from your account.

This bash script is courtesy of @gianu.

Note that tweets-raw.sh will pipe out the returned string, which is a big hairball requiring further parsing. You can see a pretty-printed sample of what you might get back in tweets-raw.json. (This map of a tweet object is outdated but still helpful.)

If you have jq installed (brew install jq), use the tweets.sh script, which extracts out the time and text of each tweet. You can see sample results in tweets.json.

Config

You first need to create a twitter “app” in order to generate some OAuth keys.

With the app created, add the following items at the top of the script:

tweet_count=5 # the number of tweets you want to retrieve
screen_name=YOUR_SCREEN_NAME
consumer_key=YOUR_CONSUMER_KEY
consumer_secret=YOUR_CONSUMER_SECRET
oauth_token=YOUR_AUTH_TOKEN
oauth_secret=YOUR_AUTH_SECRET

I.e.:

tweets-raw.sh

tweets.json

tweets.sh