flikrsearch 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/flikr.rb +42 -0
- data/lib/flikrsearch.rb +4 -0
- metadata +46 -0
data/lib/flikr.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
##
|
2
|
+
# @author Thomas Rothwell <devnull@thomasrothwell.com>
|
3
|
+
# @copyright Copyright 2013. (http://thomasrothwell.com)
|
4
|
+
# @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
5
|
+
# @version 1.0
|
6
|
+
#
|
7
|
+
# Based off: http://www.golygon.com/2010/10/ruby-on-rails-3-flickr-api-for-photo-search/
|
8
|
+
module FlikrSearch
|
9
|
+
class Request
|
10
|
+
# Flikr API Url
|
11
|
+
@@uri = URI.parse("http://api.flickr.com/services/rest/")
|
12
|
+
|
13
|
+
# Flikr API Key
|
14
|
+
@@api_key = defined?(FLIKRSEARCH_API_KEY) ? FLIKRSEARCH_API_KEY : "825e43c19f429a0a6a114b1e62d2136c"
|
15
|
+
|
16
|
+
def search (term = nil, page_number = 1, per_page = 100)
|
17
|
+
params = {
|
18
|
+
"method" => "flickr.photos.search",
|
19
|
+
"api_key" => @@api_key,
|
20
|
+
"per_page" => per_page,
|
21
|
+
"sort" => "relevance",
|
22
|
+
"media" => "photos",
|
23
|
+
"tags" => term,
|
24
|
+
"page" => page_number,
|
25
|
+
}
|
26
|
+
|
27
|
+
http = Net::HTTP.new(@@uri.host, @@uri.port)
|
28
|
+
request = Net::HTTP::Get.new(@@uri.path)
|
29
|
+
request.set_form_data(params)
|
30
|
+
|
31
|
+
# Instantiate a new Request object
|
32
|
+
request = Net::HTTP::Get.new(@@uri.path+ "?" + request.body)
|
33
|
+
response = http.request(request).body
|
34
|
+
|
35
|
+
# Convert the response into a Hash for usability
|
36
|
+
response = Hash.from_xml(response)
|
37
|
+
return response["rsp"]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
#url = “http://farm”+e.attributes['farm']+”.static.flickr.com/”+e.attributes['server']+”/”+e.attributes['id']+”_”+e.attributes['secret']+”.jpg”;
|
42
|
+
#puts FlikrSearch::Request.new.search('Pollenizer')
|
data/lib/flikrsearch.rb
ADDED
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flikrsearch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Thomas Rothwell
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Enables a user to search images on Flikr based off a specific term.
|
15
|
+
email: devnull@thomasrothwell.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/flikr.rb
|
21
|
+
- lib/flikrsearch.rb
|
22
|
+
homepage: https://github.com/TomTheBomb/FlikrSearch-Ruby-Gem
|
23
|
+
licenses: []
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 1.8.11
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: Flikr image search
|
46
|
+
test_files: []
|