Skip to content

Commit

Permalink
add search example too
Browse files Browse the repository at this point in the history
  • Loading branch information
rdp committed May 10, 2011
1 parent 7e4f68d commit 4355639
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/search.rb
@@ -0,0 +1,22 @@
require 'flickraw'

# search for pictures taken within 60 miles of new brunswick, between 1890-1920

# FlickRaw.api_key="..."
# FlickRaw.shared_secret="..."

new_b = flickr.places.find :query => "new brunswick"
latitude = new_b[0]['latitude'].to_f
longitude = new_b[0]['longitude'].to_f

# within 60 miles of new brunswick, let's use a bbox
radius = 1
args = {}
args[:bbox] = "#{longitude - radius},#{latitude - radius},#{longitude + radius},#{latitude + radius}"

# requires a limiting factor, so let's give it one
args[:min_taken_date] = '1890-01-01 00:00:00'
args[:max_taken_date] = '1920-01-01 00:00:00'
args[:accuracy] = 1 # the default is street only granularity [16], which most images aren't...
discovered_pictures = flickr.photos.search args
discovered_pictures.each{|p| url = FlickRaw.url p; puts url}
1 change: 1 addition & 0 deletions lib/flickraw.rb
Expand Up @@ -89,6 +89,7 @@ def to_a; @a end
def inspect; @a.inspect end
def size; @a.size end
def marshal_dump; [@h, @flickr_type, @a] end
alias length size
end

class FailedResponse < StandardError
Expand Down

0 comments on commit 4355639

Please sign in to comment.