Module: ETFC::Flickr
- Defined in:
- lib/etfc/flickr.rb
Class Method Summary collapse
-
.search(keyword) ⇒ Object
Public: Search for the most interesting image on flickr for a keyword.
Class Method Details
.search(keyword) ⇒ Object
Public: Search for the most interesting image on flickr for a keyword
keyword - the keyword to search for
Examples:
search('something interesting')
#=> 'http://farm9.staticflickr.com/1234/11111111111_2222222222_b.jpg'
search('something that totally wont match')
#=> nil
Returns a String (URL) for an image or nil if no image was found
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/etfc/flickr.rb', line 24 def search(keyword) # See https://www.flickr.com/services/api/flickr.photos.search.html / # http://hanklords.github.io/flickraw/FlickRaw/Flickr/Photos.html#method-i-search results = flickr.photos.search(sort: 'interestingness-desc', text: keyword, page: 1, per_page: 1, media: 'photos', content_type: 1, extras: 'url_l') results.first['url_l'] if results.size > 0 end |