Skip to content

Instantly share code, notes, and snippets.

@gerson
Created November 9, 2011 22:35
Show Gist options
  • Save gerson/1353362 to your computer and use it in GitHub Desktop.
Save gerson/1353362 to your computer and use it in GitHub Desktop.
Tracking facebook friends with me app permission
def suggested_rivals_facebook
friend_user_ids = []
if authentications.size > 0 && authentications.map(&:provider).include?("facebook")
auth = authentications.where(:provider => 'facebook').map.first
friends_application = FbGraph::Query.new("SELECT uid FROM user WHERE is_app_user=1 and uid IN (SELECT uid2 FROM friend WHERE uid1 = #{auth.uid})").fetch("#{auth.access_token}")
friends_application.collect! {|par| par["uid"].to_s}
friend_user_ids = User.where("authentications.provider" => "facebook").any_in("authentications.uid" => friends_application).not_in("_id" => rivals.map(&:competitor)).map
end
friend_user_ids
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment