Skip to content

Instantly share code, notes, and snippets.

@fmasanori
Last active September 3, 2022 13:28
Show Gist options
  • Save fmasanori/4684752 to your computer and use it in GitHub Desktop.
Save fmasanori/4684752 to your computer and use it in GitHub Desktop.
Python 3.x Facebook Friends Photos
#Sorry, in April 30, 2015, with Facebook 2.0 API update only friends that use the app will be show
import urllib.request
import json
def save_image(friend):
size = '/picture?width=200&height=200'
url = 'https://graph.facebook.com/'+ friend['id'] + size
image = urllib.request.urlopen(url).read()
f = open(friend['name'] + '.jpg', 'wb')
f.write(image)
f.close()
print (friend['name'] + '.jpg impresso')
#get the token https://developers.facebook.com/tools/explorer
url = 'https://graph.facebook.com/me/friends?access_token=EAACEdEose0cBAD5XZCz5JXYvqyeJzcSvFZC42toHiWyfjhcZCMZBZCpE3uRJnEBsrhUEMRK1wWs6SsdiDFxsI1mYwyoNuMix2XZCpvsKbZB9TumtZBlcLeIpl4pa931Ce9rTinEAhtyVVZAAZAX4NmfpBUqWtzCRC0fX5GZBn7ZC28mPKAZDZD'
resp = urllib.request.urlopen(url).read()
data = json.loads(resp.decode('utf-8'))
for friend in data['data']:
save_image(friend)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment