-
-
Save robertomiranda/1353365 to your computer and use it in GitHub Desktop.
Tracking facebook friends with me app permission
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
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