title: Programatically posting a comment in Reddit using Python
body: <p>I'm using the httplib2 library located <a href="https://code.google.com/p/httplib2/wiki/Examples#Forms" rel="nofollow">here</a></p>
  
  <p>So far my code is this:</p>
  
  <pre><code>    http = httplib2.Http()
      url= 'http://www.reddit.com/api/login'
      body= {'user' : 'DUMMYUSERNAME', 'passwd': 'DUMMYPASSWORD'}
      headers = {'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}
      response, content= http.request(url, 'POST', headers=headers, body=urllib.urlencode(body))
      headers = {'Cookie': response['set-cookie']}
  </code></pre>
  
  <p>I could be mistaken, but I believe the above code successfully logs me into reddit.com (how would I verify this?) </p>
  
  <p>The next step is sending the comment.  I took a look at the network tab in Firebug and it appears the form requires several variables:</p>
  
  <pre><code>id  #form-t3_f3oj23a4
  r   learnprogramming
  renderstyle html
  text    testing send data
  thing_id    t3_f3oj2
  uh  6qsck0zhpa2585dac6a0ab49250cbceca76fb36df883320896
  </code></pre>
  
  <p>But I'm not sure </p>
  
  <ol>
  <li>How to programatically find the requisite post data
  for each different page.  (How do I find id, thing_id, and uh for each  page?)</li>
  <li>Send that data to reddit.   </li>
  </ol>
  
  <p>Would it be something like this?</p>
  
  <pre><code>data= dict(thing_id="t3_f3oj2", text="testing", id="#form-t3_f3oj2ikj", r="learnprogramming", uh="sz4n7idqmc22bdeec21d7f2ca3e9408b102160646e2fcbbff4", renderstyle="html")
  resp, content = h.request("http://www.reddit.com/r/blahblahsubreddit/comments/f3oj2/blahblahpost/", "POST", urllib.urlencode(data))
  </code></pre>
  
  <p>Am I using the appropriate libraries?  Thanks.</p>