Created
February 11, 2012 04:00
-
-
Save bostwick/1796048 to your computer and use it in GitHub Desktop.
Facebook News Feed Word Cloud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_json(url): | |
""" Return the parsed JSON from a url. """ | |
# print "GET %s" % url | |
f = urllib2.urlopen(url) | |
return json.loads(f.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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"