title: Python - Facebook API - Need a working example
body: <p>Ok, so i've googled around, i've found threads here on stackoverflow and i've checked the official Facebook wiki and.. and what not..</p>
  
  <p>I now hope that one of you guys sits on a Facebook API sample code for Python.
  This is what i've got so far and all i get is "Invalid Signature" via PyFacebook which appears to be a dead project:</p>
  
  <pre><code>from facebook import Facebook
  
  api_key = '123456789______'
  secret  = '&lt;proper secret key&gt;'
  OTK = 'XXXXX' # &lt;-- You get this from: https://www.facebook.com/code_gen.php?v=1.0&amp;api_key=123456789______
  long_term_key = None
  
  fb = Facebook(api_key, secret)
  
  def generate_session_from_onetime_code(fb, code):
      fb.auth_token = code
      return fb.auth.getSession()
  if not long_term_key:
      long_term_key = generate_session_from_onetime_code(fb, OTK)['session_key']
      print 'Replace None with this in the .py file for long_term_key:'
      print long_term_key
  
  fb.session_key = long_term_key
  fb.uid = 000000001  # &lt;-- Your user-id
  fb.signature = api_key # &lt;-- This doesn't work at all, MD5 of what?
  #fb.validate_signature(fb) # &lt;-- doesn't work either, prob need to pass MD5 handle?
  print fb.friends.get() # &lt;-- Generates "Invalid Signature"
  </code></pre>
  
  <p>"all" i want, is to retrieve my friends list for now,
  if there's a better API point me in the right direction but Facebook has officially declared their own Python SDK dead and pyfacebook is almost working for me but not quite..</p>
  
  <p>So, please help.</p>