Created
January 17, 2013 10:55
-
-
Save svineet/4555198 to your computer and use it in GitHub Desktop.
A python program to fetch and print out the last 5 tweets made by a user(taken as input) using the twitter REST api.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
def main(): | |
handle = raw_input('Twitter handle(without @)-') | |
r = requests.get('https://api.twitter.com/1/statuses/user_timeline/'+handle+'.json?callback=?&count=5') | |
obj = json.loads(r.content) | |
for i in range(0,5): | |
print "-"*24 | |
print obj[i]['user']['name'] + " tweeted -" | |
print obj[i]['text'] | |
print "Created on " + obj[i]['user']['created_at'] | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment