Skip to content

Instantly share code, notes, and snippets.

@latompa
Created July 8, 2009 19:57
Show Gist options
  • Save latompa/143132 to your computer and use it in GitHub Desktop.
Save latompa/143132 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'lib/fleakr'
Fleakr.api_key = 'API_KEY'
Fleakr.shared_secret = 'SECRET'
MAX_TRIES = 100
user_list = [{:auth_token => "TOKEN_1", :owner_id => "USER_1"},
{:auth_token => "TOKEN_2", :owner_id => "USER_2"}]
#
# fetch the first photo for each user, and make sure that owner is owned by the user
#
threads=[]
user_list.each do |user|
threads << Thread.new(user) do |myPage|
a = -1
success = 0
error = 0
while (a+=1) < MAX_TRIES do
owner = user[:owner_id]
auth_token = user[:auth_token]
photos = Fleakr.search(:auth_token=>auth_token, :user_id => "me", :per_page => 20, :privacy_filter => "4")
is_correct_owner = (photos.first.owner_id == owner)
is_correct_owner ? success+=1 : error+=1
end
p "done, ran #{a} times, success: #{success}, error #{error}"
end
end
threads.each { |aThread| aThread.join }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment