Skip to content

Instantly share code, notes, and snippets.

@chenyanzhe
Created December 24, 2013 03:25
Show Gist options
  • Save chenyanzhe/8108389 to your computer and use it in GitHub Desktop.
Save chenyanzhe/8108389 to your computer and use it in GitHub Desktop.
Gather Geo-Tagged Tweets using Twitter Streaming API
#/bin/bash
# The KEY and SECRET below are invalidate
# Place your correct key here
# Consumer Key
key='x4Ew64IOWg5haePO78w82w'
# Consumer Secret
secret='zXsAy05cGpm1p2r4tJrpqPS7XOfQ5Z4Ga1uSMSCm0Q'
# Access Token
token='1501316798-tzio2ebnqDV3FkTIZtCSp4aJWcaYmDOPVyFW0PZ'
# Access Token Secret
token_secret='qW8Rc0sUPUPh2khkbYOrx2E2bV8HYZJ4wmrI5pGTWnu9d'
nonce=`date +%s%T%N | openssl base64 | sed -e s'/[+=/]//g' | head -c 32`
timestamp=`date +%s`
signature=`echo -n 'POST&https%3A%2F%2Fstream.twitter.com%2F1.1%2Fstatuses%2Ffilter.json&locations%3D-180%252C-90%252C180%252C90%26oauth_consumer_key%3D'$key'%26oauth_nonce%3D'$nonce'%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D'$timestamp'%26oauth_token%3D'$token'%26oauth_version%3D1.0' | openssl dgst -sha1 -hmac $secret'&'$token_secret -binary | openssl base64 | sed -e s'/+/%2B/' -e s'/\//%2F/' -e s'/=/%3D/'`
curl --request 'POST' 'https://stream.twitter.com/1.1/statuses/filter.json' --data 'locations=-180%2C-90%2C180%2C90' --header 'Authorization: OAuth oauth_consumer_key="'$key'", oauth_nonce="'$nonce'", oauth_signature="'$signature'", oauth_signature_method="HMAC-SHA1", oauth_timestamp="'$timestamp'", oauth_token="'$token'", oauth_version="1.0"' --verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment