Skip to content

Instantly share code, notes, and snippets.

@bostwick
Created February 11, 2012 04:00
Show Gist options
  • Save bostwick/1796048 to your computer and use it in GitHub Desktop.
Save bostwick/1796048 to your computer and use it in GitHub Desktop.
Facebook News Feed Word Cloud
def get_json(url):
""" Return the parsed JSON from a url. """
# print "GET %s" % url
f = urllib2.urlopen(url)
return json.loads(f.read())
def fb_feed_url(access_token):
""" The graph api url for your facebook feed. access_token should be
a valid facebook access token as a string.
"""
return "https://graph.facebook.com/me/home?access_token=%s" % access_token
def fb_news_feed(access_token, pages):
""" Returns a set number of pages from a facebook news feed as a
list of parsed json.
"""
feed_url = fb_feed_url(access_token)
page_json = []
for x in range(0, pages):
json = get_json(feed_url)
page_json.append(json)
feed_url = json['paging']['next']
return page_json
@your2
Copy link

your2 commented Jun 1, 2015

I'm a beginer. I got a trouble, but I don't know why. Please help me.
My error message code is below. Thank you~

"/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/open/PycharmProjects/untitled/facebook2.py
Traceback (most recent call last):
File "/Users/open/PycharmProjects/untitled/facebook2.py", line 117, in
access_token = sys.argv[1]
IndexError: list index out of range"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment