title: Facebook API using Python. How to print out comments from ALL post?
body: <p>I am new to Facebook API. Currently, I am trying to print out ALL the comments that have been posted for this facebook page called 'leehsienloong'. However, I could only print out a total of 700+ comments. I'm sure there are more than 700+ comments in total. </p>
  
  <p>I find out that the problem is, I did not request to go to another page to print out the comments. I read about paging Facebook API, but I still do not understand how to do the code for paging. </p>
  
  <p>Is there anyone out there who will be able to help/assist me? I really need help. Thank you.</p>
  
  <p>Here is my code, without paging:</p>
  
  <pre><code>import facebook    #sudo pip install facebook-sdk
  import itertools
  import json
  import re
  import requests
  
  access_token = "XXX"
  user = 'leehsienloong'
  
  graph = facebook.GraphAPI(access_token)
  profile = graph.get_object(user)
  posts = graph.get_connections(profile['id'], 'posts')
  
  Jstr = json.dumps(posts)
  JDict = json.loads(Jstr)
  
  count = 0
  for i in JDict['data']:
      allID = i['id']
      try:
          allComments = i['comments']
  
          for a in allComments['data']:  
              count += 1
              print a['message']
  
  
      except (UnicodeEncodeError):
          pass
  
  
  print count
  </code></pre>