Skip to content

Instantly share code, notes, and snippets.

@Dru89
Created December 6, 2012 01:04
Show Gist options
  • Save Dru89/4221049 to your computer and use it in GitHub Desktop.
Save Dru89/4221049 to your computer and use it in GitHub Desktop.
Display a list of names for people's user ids.
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