Last active
September 3, 2022 13:28
-
-
Save fmasanori/4684752 to your computer and use it in GitHub Desktop.
Python 3.x Facebook Friends Photos
This file contains 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
#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