RUBY - Facebook API - Download Photo Albums
Closed - This job posting has been filled and work has been completed.
I have a facebook app that get's the user's "user_photos" permission.
I need a simple script that will download all pictures from all photo albums of a facebook user.
Preferably you will use this gem: https://github.com/nov/fb_graph
The script will be run like this:
ruby fb_download.rb HERE_THE_CODE
As you can see, I will pass the authorization code to the script as ARGV.
I did some work myself, see below:
APP_ID = "..."
APP_SECRET = "...."
CODE = ARGV.strip # this is what Facebook will return after the user installs the App.. this is no access token
# Get Access Token:
fb_auth = FbGraph::Auth.new(APP_ID, APP_SECRET)
client = fb_auth.client
client.redirect_uri = "..." # this must match 100% with the redirect_uri when the user installs the app
client.authorization_code = CODE
access_token = client.access_token! :client_auth_body
user = FbGraph::User.me(access_token)
user = user.fetch
# Download Albums
user.albums.each do |album|
album.photos.each do |photo|