title: How to write a post on facebook using python
body: <p>I have tried with a sample code that I found on google..</p>
  
  <pre><code>import facebook
  
  def main():
     # Fill in the values noted in previous steps here
      cfg = {
      "page_id"      : "XXXXXXXXXXXXXX",  # Step 1
      "access_token" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"   # Step 3
      }
  
      api = get_api(cfg)
      msg = "Hello, world!"
      status = api.put_wall_post(msg)
  
  def get_api(cfg):
       graph = facebook.GraphAPI(cfg['access_token'])
       # Get page token to post as the page. You can skip 
       # the following if you want to post as yourself. 
       resp = graph.get_object('me/accounts')
       page_access_token = None
      for page in resp['data']:
          if page['id'] == cfg['page_id']:
              page_access_token = page['access_token']
      graph = facebook.GraphAPI(page_access_token)
      return graph
  
  if __name__ == "__main__":
       main()
  </code></pre>
  
  <p>But I am getting this error:</p>
  
  <blockquote>
    <p>AssertionError: Write operations require an access token on line  <code>status = api.put_wall_post(msg)</code>. </p>
  </blockquote>
  
  <p>Can some one help me in solving the issue?</p>
  
  <p><img src="https://i.stack.imgur.com/arJTq.png" alt="images"></p>