Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Created November 30, 2013 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelcaraciolo/7715862 to your computer and use it in GitHub Desktop.
Save marcelcaraciolo/7715862 to your computer and use it in GitHub Desktop.
import urllib.request
import json
def grava_imagem(amigo):
size = '/picture?width=200&height=200'
url = 'https://graph.facebook.com/'+ amigo['id'] + size
figura = urllib.request.urlopen(url).read()
f = open(amigo['name'] + '.jpg', 'wb')
f.write(figura)
f.close()
print (amigo['name'] + '.jpg impresso')
#get the token https://developers.facebook.com/tools/explorer
url = 'https://graph.facebook.com/me/friends?access_token=<token>'
resp = urllib.request.urlopen(url).read()
dados = json.loads(resp.decode('utf-8'))
for amigo in dados['data']:
grava_imagem(amigo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment