TankorSmash

Reddit API Login

Apr 24th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import requests
  2. #----------------------------------------------------------------------
  3. def login(username, password):
  4.     """logs into reddit, saves cookie"""
  5.    
  6.     print 'begin log in'
  7.     #username and password
  8.     UP = {'user': username, 'passwd': password, 'api_type': 'json',}
  9.    
  10.     #POST with user/pwd
  11.    
  12.     r = requests.post('http://www.reddit.com/api/login', data=UP)
  13.  
  14.     #read this to make sure no errors
  15.     print r.text
  16.    
  17.    
  18. login('USERNAMEHERE', 'PASSWORDHERE')
Add Comment
Please, Sign In to add comment