Twitter API fun scripts using Tweepy in Python. I'm hoping people can use these examples as repository to draw on when they develop their own scripts.
-
$ python recommend.py blahblah
: gives recommendations to user 'blahblah' on who to follow, based on their social graph on twitter. It looks for people who are very often followed by blahblah's followers, but who 'blahblah' doesn't follow. -
$ python userstream.py
: prints authenticated user's timeline, live -
$ python followersdiff.py
: finds all your followers and saves them to local file. Re-running the script will do a diff with that file so you can see who followed or unfollowed you since last time you ran the script.
-
Install tweepy:
$ easy_install tweepy
(requires:$ sudo apt-get install python-setuptools
) -
Follow this excellent tutorial to set up oauth access.
-
Once you register an app on Twitter they will give you 4 strings: consumer key, consumer secret, access key, and access secret. Create a new file called
tconf
in the folder where you keep twoolpy and enter the 4 strings one per line, in order listed above (consumer key, consumer secret, access key, and access secret). -
run
$ python authest.py
to make sure everything is setup right. If yes, some people's names will be printed, or error will result.
WTFPL licence