Advertisement
johnmahugu

PYTHON >>> Twitter API

May 6th, 2016
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1.  
  2. # Use the python-twitter library to authenticate with the Twitter API,
  3. # fetch a user, and then print a selection of data. After that, fetch
  4. # a user timeline and print some statuses.
  5.  
  6. import twitter
  7.  
  8. api = twitter.Api(consumer_key='your-consumer-key',
  9.                   consumer_secret='your-consumer-secret',
  10.                   access_token_key='your-access-token-key',
  11.                   access_token_secret='your-access-token-secret')
  12.  
  13. # set a handle
  14. handle = 'anthonydb'
  15.  
  16. # Get some info on a user
  17. user = api.GetUser(screen_name=handle)
  18.  
  19. print user.GetName()
  20. print user.GetDescription()
  21. print user.GetFollowersCount()
  22. print user.GetStatusesCount()
  23. print user.GetUrl()
  24.  
  25. # get a user timeline
  26. statuses = api.GetUserTimeline(screen_name='pokjournal', count=1)
  27. print [s.text for s in statuses]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement