Skip to content

Instantly share code, notes, and snippets.

@korczis
Created July 23, 2013 08:56
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 korczis/6060957 to your computer and use it in GitHub Desktop.
Save korczis/6060957 to your computer and use it in GitHub Desktop.
require 'koala'
require 'pp'
# Get the token from https://developers.facebook.com/tools/explorer
OAUTH_TOKEN = "SET_YOUR_TOKEN_HERE"
@api = Koala::Facebook::API.new(OAUTH_TOKEN)
profile = @api.get_object("me")
friends = @api.get_connections("me", "friends")
# puts JSON.pretty_generate(friends)
query = "SELECT pid, caption, aid, owner, link, src_big, src_small, created, modified FROM photo WHERE aid IN (SELECT aid FROM album WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())) AND created > 0 ORDER BY created DESC"
fql = @api.fql_query(query)
pp fql
pp " => Total #{fql.length}"
fql.each_with_index do |i, idx|
url = i['src_big']
pp "#{idx+1}/#{fql.length} - #{url}"
system "wget #{url}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment