require 'redis'
require 'face'
# fb user_id of the user that needs to be find on match.com
FB_UID = '11111@facebook.com'
# show all profiles whith the given confidence of recognition
ACCURACY = 30
redis = Redis.new
pictures = redis.hgetall("people")
# recognize user
client = Face.get_client(:api_key => FACECOM_APIKEY, :api_secret => FACECOM_APISECRET)
# note in fb_user you pass here YOUR fb user id, not an id of the user your are looking for
client.facebook_credentials = {:fb_user => YOUR_FB_USER_ID, :fb_oauth_token =>YOUR_FB_OAUTH_TOKEN}
#train pictures
response = client.faces_train(:uids => [FB_UID] )
pictures.keys.each_slice(20) do |pictures_chunk|
response = client.faces_recognize(:urls => pictures_chunk, :uids => [FB_UID])
response["photos"].each do |photo|
photo["tags"].each{|tag|
next if tag.nil? || tag['uids'].empty?
p "Profile found, #{pictures[photo['url']]}, confidence #{tag['uids'][0]['confidence']}" if tag['uids'][0]['confidence'].to_i > ACCURACY
}
end
end