Skip to content

Instantly share code, notes, and snippets.

@messick
Created April 24, 2012 21:57
Show Gist options
  • Save messick/2484172 to your computer and use it in GitHub Desktop.
Save messick/2484172 to your computer and use it in GitHub Desktop.
Audit Users against Facebook Graph Information
bad_fb = []
exception = []
# Create a new file and write to it
File.open('/Users/developer/Documents/results.csv', 'w') do |f|
User.where("'facebook_access_token' IS NOT NULL").each do |u|
unless u.facebook_access_token.nil?
begin
@graph = Koala::Facebook::API.new(u.facebook_access_token)
profile = @graph.get_object("me")
if u.facebook_id != profile['id'] || u.email != profile['email']
bad_fb << u
f.puts "#{u.id},#{u.login},#{u.email},#{u.facebook_id},#{u.facebook_access_token},#{profile['id']},#{profile['name']},#{profile['email']}"
end
rescue StandardError => e
exception << e
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment