Created
April 24, 2012 21:57
-
-
Save messick/2484172 to your computer and use it in GitHub Desktop.
Audit Users against Facebook Graph Information
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
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