Search code examples
facebookparsingsocial-mediamining

How to get ALL posts and statuses from a facebook fan page?


In IPython, I do

urlopen('https://graph.facebook.com/18888909708/posts?access_token=my_access_token').read() 

but it returns posts going back only one month.

How do I get posts going back, if not to the creation of the page, as far as possible.

Thanks.


Solution

  • I figured it out. The Facebook Social Graph API has a since() and until() option.

    For instance, you can grab posts in between two dates like so

    access_token = 'YOUR_ACCESS_TOKEN'
    fanpage = 'taylorswift'
    startDate = '02/02/12'
    endDate = '02/02/14'
    url = https://graph.facebook.com/'fanpage'?fields=posts.limit(500).since('startDate').until('endDate').fields(message)&access_token=%s' % (access_token)
    

    Then it'll return a json file that can be cleaned up and analyzed.