Created
December 6, 2012 01:04
-
-
Save Dru89/4221049 to your computer and use it in GitHub Desktop.
Display a list of names for people's user ids.
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
import json | |
import urllib2 | |
facebook_ids = [] # Input ids here like ["1234567890", "1234567890", "1234567890", "1234567890"] | |
to_show = 15 # how many profiles do you want to see? | |
def get_name_for(id): | |
return json.loads(urllib2.urlopen("http://graph.facebook.com/{0}".format(id)).read())["name"] | |
print "Showing top {0} users (out of {1})".format(to_show, len(facebook_ids)) | |
for i, value in enumerate(facebook_ids[:to_show]): | |
print "{0:<5} {1}".format(i, get_name_for(id=value)) | |
""" | |
The output will look like this: | |
1 Bob Testerson | |
2 James Norville | |
3 Some Random Guy | |
4 Blah Blah Blah | |
... | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment