flickr.rb 1.1.2 → 1.2.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.
- checksums.yaml +4 -4
- data/Changelog.txt +8 -0
- data/Gemfile.lock +2 -2
- data/README.md +115 -0
- data/Rakefile +1 -1
- data/flickr.gemspec +2 -2
- data/lib/flickr.rb +20 -7
- data/rdoc/Flickr.html +182 -141
- data/rdoc/Flickr/Config.html +103 -70
- data/rdoc/Flickr/Group.html +104 -74
- data/rdoc/Flickr/Photo.html +205 -174
- data/rdoc/Flickr/PhotoCollection.html +98 -66
- data/rdoc/Flickr/Photoset.html +107 -77
- data/rdoc/Flickr/User.html +137 -107
- data/rdoc/{README_txt.html → README_md.html} +141 -88
- data/rdoc/created.rid +3 -3
- data/rdoc/index.html +36 -48
- data/rdoc/js/darkfish.js +15 -0
- data/rdoc/js/search.js +5 -20
- data/rdoc/js/search_index.js +1 -1
- data/rdoc/rdoc.css +241 -226
- data/rdoc/table_of_contents.html +194 -426
- data/test/flickr_test.rb +16 -1
- metadata +4 -11
- data/README.txt +0 -92
- data/rdoc/fonts.css +0 -167
- data/rdoc/fonts/Lato-Light.ttf +0 -0
- data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
- data/rdoc/fonts/Lato-Regular.ttf +0 -0
- data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2839dc51d7158f2dd122918426745eba5ebac3b
|
4
|
+
data.tar.gz: f22833fed59a888c2121bac68b068f0347082809
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09fb1d306927fede79b5433cf5030d5751c70b7fbf4a3e221898515eb2df56d0f08b17362e0d924b85fac3a72e2a3722c9ae62f9fcfadacd3ce08c9285d66b71
|
7
|
+
data.tar.gz: 08679aabcefc91079ca7b606e2264bcce19301fdcdabc737fd49b8514c9dc5575fe0cb979ede9445bdcae89493d438f9edd91c279fdc84d65aaf16ea8a8cb934
|
data/Changelog.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
1.2.0 2014-05-13
|
2
|
+
* New image sizes support: Large square, Small 320, Medium 640 - #5 - https://github.com/RaVbaker/flickr/issues/5
|
3
|
+
* SSL support for requests to Flickr API - #4 - https://github.com/RaVbaker/flickr/issues/4
|
4
|
+
This change might not be backward compatible so I changed gem version to 1.2. See README.md for more info about SSL
|
5
|
+
|
6
|
+
1.1.2 2014-04-17
|
7
|
+
* No changes at all. I failed to set a gem update date for 1.1.1
|
8
|
+
|
1
9
|
1.1.1 2014-04-17
|
2
10
|
* Migrated to usage of Bundler for dependency tracking
|
3
11
|
* Fixes retrieving list of photos no matter which sibling they are in XML structure
|
data/Gemfile.lock
CHANGED
data/README.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# flickr.rb
|
2
|
+
|
3
|
+
http://github.com/RaVbaker/flickr
|
4
|
+
|
5
|
+
[](http://badge.fury.io/rb/flickr.rb)
|
6
|
+
|
7
|
+
## DESCRIPTION:
|
8
|
+
|
9
|
+
An insanely easy interface to the Flickr photo-sharing service. By Scott Raymond. (& updated May 2008 by Chris Taggart, http://pushrod.wordpress.com & maintained since May 2010 by me - Rafal Piekarski)
|
10
|
+
|
11
|
+
It's a simple interface for using Flickr API - [https://www.flickr.com/services/api/](https://www.flickr.com/services/api/)
|
12
|
+
|
13
|
+
## FEATURES/PROBLEMS:
|
14
|
+
|
15
|
+
The flickr gem (famously featured in a RubyonRails screencast) had broken with Flickr's new authentication scheme and updated API.
|
16
|
+
This has now been largely corrected, though not all current API calls are supported yet. If you need something let me know in pull requests.
|
17
|
+
|
18
|
+
## SYNOPSIS:
|
19
|
+
|
20
|
+
require 'flickr'
|
21
|
+
flickr = Flickr.new('some_flickr_api_key') # create a flickr client (get an API key from http://api.flickr.com/services/api/)
|
22
|
+
user = flickr.users('sco@scottraymond.net') # lookup a user
|
23
|
+
user.name # get the user's name
|
24
|
+
user.location # and location
|
25
|
+
user.photos # grab their collection of Photo objects...
|
26
|
+
user.groups # ...the groups they're in...
|
27
|
+
user.contacts # ...their contacts...
|
28
|
+
user.favorites # ...favorite photos...
|
29
|
+
user.photosets # ...their photo sets...
|
30
|
+
user.tags # ...their tags...
|
31
|
+
user.popular_tags # ...and their popular tags
|
32
|
+
recentphotos = flickr.photos # get the 100 most recent public photos
|
33
|
+
photo = recentphotos.first # or very most recent one
|
34
|
+
photo.url # see its URL,
|
35
|
+
photo.title # title,
|
36
|
+
photo.description # and description,
|
37
|
+
photo.owner # and its owner.
|
38
|
+
File.open(photo.filename, 'w') do |file|
|
39
|
+
file.puts p.file # save the photo to a local file
|
40
|
+
end
|
41
|
+
flickr.photos.each do |p| # get the last 100 public photos...
|
42
|
+
File.open(p.filename, 'w') do |f|
|
43
|
+
f.puts p.file('Square') # ...and save a local copy of their square thumbnail
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
## REQUIREMENTS:
|
48
|
+
|
49
|
+
* Xmlsimple gem
|
50
|
+
|
51
|
+
## INSTALLATION:
|
52
|
+
|
53
|
+
Add this line to your application's Gemfile:
|
54
|
+
|
55
|
+
gem 'flickr.rb'
|
56
|
+
|
57
|
+
And then execute:
|
58
|
+
|
59
|
+
$ bundle
|
60
|
+
|
61
|
+
Or install it yourself as:
|
62
|
+
|
63
|
+
$ gem install flickr.rb
|
64
|
+
|
65
|
+
|
66
|
+
* Gem homepage: [http://rubygems.org/gems/flickr.rb](http://rubygems.org/gems/flickr.rb)
|
67
|
+
|
68
|
+
## CONFIGURING:
|
69
|
+
|
70
|
+
You can provide just a api_key `Flickr.new('api_key')` or full set of advanced configuration options:
|
71
|
+
|
72
|
+
flickr = Flickr.new(
|
73
|
+
api_key: 'your_api_key',
|
74
|
+
shared_secret: 'shared_secret_code',
|
75
|
+
auth_token: 'authSecretToken',
|
76
|
+
verify_ssl: true,
|
77
|
+
ca_file: '/path/to/cert.pem'
|
78
|
+
)
|
79
|
+
|
80
|
+
As you see you can turn off ssl verification (`verify_ssl: false`) or provide your own CA file (`:ca_file` option) for SSL verification. By default gem uses the `OpenSSL::X509::DEFAULT_CERT_FILE` definitions.
|
81
|
+
|
82
|
+
|
83
|
+
If you want to use this gem/plugin with Rails (for version 3) you can create configuration file in /config directory with specified api connection settings. For example:
|
84
|
+
|
85
|
+
development:
|
86
|
+
api_key: SomeLongApiKey
|
87
|
+
shared_secret: secret!
|
88
|
+
auth_token: authSecretToken
|
89
|
+
|
90
|
+
beta:
|
91
|
+
api_key: SomeLongApiKeyBeta
|
92
|
+
shared_secret: secretBeta!
|
93
|
+
auth_token: authSecretTokenBeta
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
## CONTRIBUTING
|
98
|
+
|
99
|
+
1. Fork it
|
100
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
101
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
102
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
103
|
+
5. Create new Pull Request
|
104
|
+
|
105
|
+
## THANKS
|
106
|
+
|
107
|
+
* Scott Raymond
|
108
|
+
* Patrick Plattes
|
109
|
+
* Chris Taggart
|
110
|
+
|
111
|
+
## LICENSE
|
112
|
+
|
113
|
+
MIT License , see `LICENSE` for more details.
|
114
|
+
|
115
|
+
© 2010 - 2014 Rafal "RaVbaker" Piekarski
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
18
18
|
rdoc.rdoc_dir = 'rdoc'
|
19
19
|
rdoc.title = 'Flickr'
|
20
20
|
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
-
rdoc.rdoc_files.include('README.
|
21
|
+
rdoc.rdoc_files.include('README.md')
|
22
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
23
|
end
|
24
24
|
|
data/flickr.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'flickr.rb'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.2.0'
|
4
4
|
s.authors = ['Scott Raymond, Patrick Plattes, Rafal Piekarski']
|
5
5
|
s.autorequire = 'flickr.rb'
|
6
|
-
s.date = '2014-
|
6
|
+
s.date = '2014-05-13'
|
7
7
|
s.email = 'ravbaker@gmail.com'
|
8
8
|
s.files = Dir.glob("**/*").delete_if { |item| item.include?(".git") || item[/^pkg/] }
|
9
9
|
s.homepage = 'http://github.com/RaVbaker/flickr/'
|
data/lib/flickr.rb
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
|
36
36
|
require 'cgi'
|
37
|
-
require 'net/
|
37
|
+
require 'net/https'
|
38
38
|
require 'xmlsimple'
|
39
39
|
require 'digest/md5'
|
40
40
|
|
@@ -43,7 +43,7 @@ class Flickr
|
|
43
43
|
attr_reader :api_key, :auth_token
|
44
44
|
attr_accessor :user
|
45
45
|
|
46
|
-
HOST_URL = '
|
46
|
+
HOST_URL = 'https://api.flickr.com'
|
47
47
|
API_PATH = '/services/rest'
|
48
48
|
|
49
49
|
# Flickr, annoyingly, uses a number of representations to specify the size
|
@@ -59,9 +59,12 @@ class Flickr
|
|
59
59
|
# "http://farm4.static.flickr.com/3118/2397458775_2ec2ddc324_m.jpg".
|
60
60
|
# The VALID_SIZES hash associates the correct letter with a label
|
61
61
|
VALID_SIZES = { "Square" => ["s", "sq"],
|
62
|
+
"Large Square" => ["q", "q"],
|
62
63
|
"Thumbnail" => ["t", "t"],
|
63
64
|
"Small" => ["m", "s"],
|
65
|
+
"Small 320" => ["n", "n"],
|
64
66
|
"Medium" => [nil, "m"],
|
67
|
+
"Medium 640" => ["z", "z"],
|
65
68
|
"Large" => ["b", "l"]
|
66
69
|
}
|
67
70
|
|
@@ -72,12 +75,13 @@ class Flickr
|
|
72
75
|
# private photos)
|
73
76
|
# There are two ways to initialize the Flickr client. The preferred way is with
|
74
77
|
# a hash of params, e.g. 'api_key' => 'your_api_key', 'shared_secret' =>
|
75
|
-
# 'shared_secret_code'
|
76
|
-
# RAILS_ROOT/config/flickr.api.yml
|
77
|
-
# specified for every environment.
|
78
|
+
# 'shared_secret_code', 'verify_ssl' => true, 'ca_file' => '/path/to/cert.pem'.
|
79
|
+
# Other way is to use in Rails an config file RAILS_ROOT/config/flickr.api.yml
|
80
|
+
# and there use params as key/values even specified for every environment.
|
78
81
|
def initialize(api_key_or_params={})
|
79
82
|
@host = HOST_URL
|
80
83
|
@api = API_PATH
|
84
|
+
@verify_ssl = true
|
81
85
|
api_key_or_params={} if api_key_or_params.nil? # fix for nil value as argument
|
82
86
|
api_key_or_params = {:api_key => api_key_or_params} if api_key_or_params.is_a?(String)
|
83
87
|
api_key_or_params = Config.get if Config.parsed? and api_key_or_params.empty?
|
@@ -88,6 +92,8 @@ class Flickr
|
|
88
92
|
@api_key = api_key_or_params[:api_key]
|
89
93
|
@shared_secret = api_key_or_params[:shared_secret]
|
90
94
|
@auth_token = api_key_or_params[:auth_token]
|
95
|
+
@ca_file = api_key_or_params[:ca_file]
|
96
|
+
@verify_ssl = !(api_key_or_params[:verify_ssl].to_s === 'false')
|
91
97
|
end
|
92
98
|
|
93
99
|
# Gets authentication token given a Flickr frob, which is returned when user
|
@@ -163,7 +169,7 @@ class Flickr
|
|
163
169
|
|
164
170
|
# Returns url for user to login in to Flickr to authenticate app for a user
|
165
171
|
def login_url(perms)
|
166
|
-
"
|
172
|
+
"https://flickr.com/services/auth/?api_key=#{@api_key}&perms=#{perms}&api_sig=#{signature_from('api_key'=>@api_key, 'perms' => perms)}"
|
167
173
|
end
|
168
174
|
|
169
175
|
# Implements everything else.
|
@@ -176,7 +182,14 @@ class Flickr
|
|
176
182
|
|
177
183
|
# Does an HTTP GET on a given URL and returns the response body
|
178
184
|
def http_get(url)
|
179
|
-
|
185
|
+
url = URI.parse(url)
|
186
|
+
http = Net::HTTP.new url.host, url.port
|
187
|
+
http.use_ssl = true
|
188
|
+
http.verify_mode = (@verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE)
|
189
|
+
http.ca_file = @ca_file if @ca_file
|
190
|
+
http.start do |res|
|
191
|
+
res.request_get(url).body.to_s
|
192
|
+
end
|
180
193
|
end
|
181
194
|
|
182
195
|
# Takes a Flickr API method name and set of parameters; returns an XmlSimple object with the response
|
data/rdoc/Flickr.html
CHANGED
@@ -2,76 +2,76 @@
|
|
2
2
|
|
3
3
|
<html>
|
4
4
|
<head>
|
5
|
-
<meta charset=
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
6
|
|
7
7
|
<title>class Flickr - Flickr</title>
|
8
8
|
|
9
|
-
<link href="./
|
10
|
-
<link href="./rdoc.css" rel="stylesheet">
|
9
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
11
10
|
|
12
11
|
<script type="text/javascript">
|
13
12
|
var rdoc_rel_prefix = "./";
|
14
13
|
</script>
|
15
14
|
|
16
|
-
<script src="./js/jquery.js"></script>
|
17
|
-
<script src="./js/navigation.js"></script>
|
18
|
-
<script src="./js/search_index.js"></script>
|
19
|
-
<script src="./js/search.js"></script>
|
20
|
-
<script src="./js/searcher.js"></script>
|
21
|
-
<script src="./js/darkfish.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
|
22
21
|
|
23
22
|
|
24
|
-
<body id="top"
|
25
|
-
<nav
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
<a href="./index.html" rel="home">Home</a>
|
30
|
-
</h2>
|
31
|
-
|
32
|
-
<div id="table-of-contents-navigation">
|
33
|
-
<a href="./table_of_contents.html#pages">Pages</a>
|
23
|
+
<body id="top" class="class">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="./index.html">Home</a>
|
34
28
|
<a href="./table_of_contents.html#classes">Classes</a>
|
35
29
|
<a href="./table_of_contents.html#methods">Methods</a>
|
36
|
-
</
|
37
|
-
</
|
30
|
+
</h3>
|
31
|
+
</nav>
|
38
32
|
|
39
|
-
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
40
35
|
<form action="#" method="get" accept-charset="utf-8">
|
41
|
-
<
|
42
|
-
<input
|
43
|
-
aria-autocomplete="list" aria-controls="search-results"
|
44
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
45
38
|
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
-
</
|
47
|
-
|
48
|
-
<ul id="search-results" aria-label="Search Results"
|
49
|
-
aria-busy="false" aria-expanded="false"
|
50
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
39
|
+
</h3>
|
51
40
|
</form>
|
52
|
-
</div>
|
53
41
|
|
54
|
-
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
55
45
|
|
56
46
|
|
57
47
|
|
58
|
-
<div id="
|
48
|
+
<div id="file-metadata">
|
49
|
+
<nav id="file-list-section" class="section">
|
50
|
+
<h3 class="section-header">Defined In</h3>
|
51
|
+
<ul>
|
52
|
+
<li>lib/flickr.rb
|
53
|
+
</ul>
|
54
|
+
</nav>
|
55
|
+
|
59
56
|
|
60
|
-
|
61
|
-
<h3>Parent</h3>
|
57
|
+
</div>
|
62
58
|
|
59
|
+
<div id="class-metadata">
|
60
|
+
|
61
|
+
<nav id="parent-class-section" class="section">
|
62
|
+
<h3 class="section-header">Parent</h3>
|
63
63
|
|
64
64
|
<p class="link">Object
|
65
65
|
|
66
|
-
</
|
66
|
+
</nav>
|
67
67
|
|
68
68
|
|
69
69
|
|
70
70
|
<!-- Method Quickref -->
|
71
|
-
<
|
72
|
-
<h3>Methods</h3>
|
71
|
+
<nav id="method-list-section" class="section">
|
72
|
+
<h3 class="section-header">Methods</h3>
|
73
73
|
|
74
|
-
<ul class="link-list"
|
74
|
+
<ul class="link-list">
|
75
75
|
|
76
76
|
<li ><a href="#method-c-new">::new</a>
|
77
77
|
|
@@ -116,21 +116,54 @@
|
|
116
116
|
<li ><a href="#method-i-users">#users</a>
|
117
117
|
|
118
118
|
</ul>
|
119
|
-
</
|
119
|
+
</nav>
|
120
|
+
|
121
|
+
</div>
|
122
|
+
|
123
|
+
<div id="project-metadata">
|
124
|
+
<nav id="fileindex-section" class="section project-section">
|
125
|
+
<h3 class="section-header">Pages</h3>
|
126
|
+
|
127
|
+
<ul>
|
128
|
+
|
129
|
+
<li class="file"><a href="./README_md.html">README</a>
|
130
|
+
|
131
|
+
</ul>
|
132
|
+
</nav>
|
133
|
+
|
134
|
+
<nav id="classindex-section" class="section project-section">
|
135
|
+
<h3 class="section-header">Class and Module Index</h3>
|
136
|
+
|
137
|
+
<ul class="link-list">
|
138
|
+
|
139
|
+
<li><a href="./Flickr.html">Flickr</a>
|
140
|
+
|
141
|
+
<li><a href="./Flickr/Config.html">Flickr::Config</a>
|
142
|
+
|
143
|
+
<li><a href="./Flickr/Group.html">Flickr::Group</a>
|
144
|
+
|
145
|
+
<li><a href="./Flickr/Photo.html">Flickr::Photo</a>
|
146
|
+
|
147
|
+
<li><a href="./Flickr/PhotoCollection.html">Flickr::PhotoCollection</a>
|
148
|
+
|
149
|
+
<li><a href="./Flickr/Photoset.html">Flickr::Photoset</a>
|
150
|
+
|
151
|
+
<li><a href="./Flickr/User.html">Flickr::User</a>
|
152
|
+
|
153
|
+
</ul>
|
154
|
+
</nav>
|
120
155
|
|
121
156
|
</div>
|
122
157
|
</nav>
|
123
158
|
|
124
|
-
<
|
125
|
-
<h1
|
126
|
-
class Flickr
|
127
|
-
</h1>
|
159
|
+
<div id="documentation">
|
160
|
+
<h1 class="class">class Flickr</h1>
|
128
161
|
|
129
|
-
<
|
162
|
+
<div id="description" class="description">
|
130
163
|
|
131
164
|
<p><a href="Flickr.html">Flickr</a> client class. Requires an API key</p>
|
132
165
|
|
133
|
-
</
|
166
|
+
</div><!-- description -->
|
134
167
|
|
135
168
|
|
136
169
|
|
@@ -141,25 +174,24 @@
|
|
141
174
|
|
142
175
|
|
143
176
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
</header>
|
177
|
+
<!-- Constants -->
|
178
|
+
<section id="constants-list" class="section">
|
179
|
+
<h3 class="section-header">Constants</h3>
|
148
180
|
<dl>
|
149
181
|
|
150
182
|
<dt id="API_PATH">API_PATH
|
151
183
|
|
152
|
-
<dd>
|
184
|
+
<dd class="description">
|
153
185
|
|
154
186
|
|
155
187
|
<dt id="HOST_URL">HOST_URL
|
156
188
|
|
157
|
-
<dd>
|
189
|
+
<dd class="description">
|
158
190
|
|
159
191
|
|
160
192
|
<dt id="VALID_SIZES">VALID_SIZES
|
161
193
|
|
162
|
-
<dd><p><a href="Flickr.html">Flickr</a>, annoyingly, uses a number of
|
194
|
+
<dd class="description"><p><a href="Flickr.html">Flickr</a>, annoyingly, uses a number of
|
163
195
|
representations to specify the size of a photo, depending on the context.
|
164
196
|
It gives a label such a “Small” or “Medium” to a size of photo, when
|
165
197
|
returning all possible sizes. However, when generating the uri for the page
|
@@ -180,10 +212,9 @@ correct letter with a label</p>
|
|
180
212
|
|
181
213
|
|
182
214
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
</header>
|
215
|
+
<!-- Attributes -->
|
216
|
+
<section id="attribute-method-details" class="method-section section">
|
217
|
+
<h3 class="section-header">Attributes</h3>
|
187
218
|
|
188
219
|
|
189
220
|
<div id="attribute-i-api_key" class="method-detail">
|
@@ -225,14 +256,13 @@ correct letter with a label</p>
|
|
225
256
|
</div>
|
226
257
|
</div>
|
227
258
|
|
228
|
-
</section
|
259
|
+
</section><!-- attribute-method-details -->
|
229
260
|
|
230
261
|
|
262
|
+
<!-- Methods -->
|
231
263
|
|
232
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
233
|
-
|
234
|
-
<h3>Public Class Methods</h3>
|
235
|
-
</header>
|
264
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
265
|
+
<h3 class="section-header">Public Class Methods</h3>
|
236
266
|
|
237
267
|
|
238
268
|
<div id="method-c-new" class="method-detail ">
|
@@ -255,39 +285,40 @@ also need a shared secret code if you want to use authentication (e.g. to
|
|
255
285
|
get a user's private photos) There are two ways to initialize the <a
|
256
286
|
href="Flickr.html">Flickr</a> client. The preferred way is with a hash of
|
257
287
|
params, e.g. 'api_key' => 'your_api_key',
|
258
|
-
'shared_secret' => 'shared_secret_code'
|
259
|
-
|
260
|
-
|
288
|
+
'shared_secret' => 'shared_secret_code',
|
289
|
+
'verify_ssl' => true, 'ca_file' =>
|
290
|
+
'/path/to/cert.pem'. Other way is to use in Rails an config file
|
291
|
+
RAILS_ROOT/config/flickr.api.yml and there use params as key/values even
|
292
|
+
specified for every environment.</p>
|
261
293
|
|
262
294
|
|
263
295
|
|
264
296
|
|
265
297
|
<div class="method-source-code" id="new-source">
|
266
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
298
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 81</span>
|
267
299
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">api_key_or_params</span>={})
|
268
300
|
<span class="ruby-ivar">@host</span> = <span class="ruby-constant">HOST_URL</span>
|
269
301
|
<span class="ruby-ivar">@api</span> = <span class="ruby-constant">API_PATH</span>
|
302
|
+
<span class="ruby-ivar">@verify_ssl</span> = <span class="ruby-keyword">true</span>
|
270
303
|
<span class="ruby-identifier">api_key_or_params</span>={} <span class="ruby-keyword">if</span> <span class="ruby-identifier">api_key_or_params</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-comment"># fix for nil value as argument</span>
|
271
304
|
<span class="ruby-identifier">api_key_or_params</span> = {<span class="ruby-value">:api_key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">api_key_or_params</span>} <span class="ruby-keyword">if</span> <span class="ruby-identifier">api_key_or_params</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
|
272
305
|
<span class="ruby-identifier">api_key_or_params</span> = <span class="ruby-constant">Config</span>.<span class="ruby-identifier">get</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">Config</span>.<span class="ruby-identifier">parsed?</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">api_key_or_params</span>.<span class="ruby-identifier">empty?</span>
|
273
306
|
<span class="ruby-identifier">set_up_configuration</span> <span class="ruby-identifier">api_key_or_params</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">api_key_or_params</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
|
274
307
|
<span class="ruby-keyword">end</span></pre>
|
275
|
-
</div
|
308
|
+
</div><!-- new-source -->
|
276
309
|
|
277
310
|
</div>
|
278
311
|
|
279
312
|
|
280
313
|
|
281
314
|
|
282
|
-
</div
|
315
|
+
</div><!-- new-method -->
|
283
316
|
|
284
317
|
|
285
|
-
</section
|
318
|
+
</section><!-- public-class-method-details -->
|
286
319
|
|
287
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
288
|
-
|
289
|
-
<h3>Public Instance Methods</h3>
|
290
|
-
</header>
|
320
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
321
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
291
322
|
|
292
323
|
|
293
324
|
<div id="method-i-find_by_url" class="method-detail ">
|
@@ -309,19 +340,19 @@ params as key/values even specified for every environment.</p>
|
|
309
340
|
|
310
341
|
|
311
342
|
<div class="method-source-code" id="find_by_url-source">
|
312
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
343
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 113</span>
|
313
344
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">find_by_url</span>(<span class="ruby-identifier">url</span>)
|
314
345
|
<span class="ruby-identifier">response</span> = <span class="ruby-identifier">urls_lookupUser</span>(<span class="ruby-string">'url'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">url</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-identifier">urls_lookupGroup</span>(<span class="ruby-string">'url'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">url</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
|
315
346
|
(<span class="ruby-identifier">response</span>[<span class="ruby-string">'user'</span>]) <span class="ruby-operator">?</span> <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">response</span>[<span class="ruby-string">'user'</span>][<span class="ruby-string">'id'</span>], <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-ivar">@api_key</span>) <span class="ruby-operator">:</span> <span class="ruby-constant">Group</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">response</span>[<span class="ruby-string">'group'</span>][<span class="ruby-string">'id'</span>], <span class="ruby-ivar">@api_key</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">nil?</span>
|
316
347
|
<span class="ruby-keyword">end</span></pre>
|
317
|
-
</div
|
348
|
+
</div><!-- find_by_url-source -->
|
318
349
|
|
319
350
|
</div>
|
320
351
|
|
321
352
|
|
322
353
|
|
323
354
|
|
324
|
-
</div
|
355
|
+
</div><!-- find_by_url-method -->
|
325
356
|
|
326
357
|
|
327
358
|
<div id="method-i-get_token_from" class="method-detail ">
|
@@ -346,7 +377,7 @@ which made the request</p>
|
|
346
377
|
|
347
378
|
|
348
379
|
<div class="method-source-code" id="get_token_from-source">
|
349
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
380
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 102</span>
|
350
381
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_token_from</span>(<span class="ruby-identifier">frob</span>)
|
351
382
|
<span class="ruby-identifier">auth_response</span> = <span class="ruby-identifier">request</span>(<span class="ruby-string">"auth.getToken"</span>, <span class="ruby-value">:frob</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">frob</span>)[<span class="ruby-string">'auth'</span>]
|
352
383
|
<span class="ruby-ivar">@auth_token</span> = <span class="ruby-identifier">auth_response</span>[<span class="ruby-string">'token'</span>]
|
@@ -356,14 +387,14 @@ which made the request</p>
|
|
356
387
|
<span class="ruby-string">'client'</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">self</span>)
|
357
388
|
<span class="ruby-ivar">@auth_token</span>
|
358
389
|
<span class="ruby-keyword">end</span></pre>
|
359
|
-
</div
|
390
|
+
</div><!-- get_token_from-source -->
|
360
391
|
|
361
392
|
</div>
|
362
393
|
|
363
394
|
|
364
395
|
|
365
396
|
|
366
|
-
</div
|
397
|
+
</div><!-- get_token_from-method -->
|
367
398
|
|
368
399
|
|
369
400
|
<div id="method-i-groups" class="method-detail ">
|
@@ -385,7 +416,7 @@ which made the request</p>
|
|
385
416
|
|
386
417
|
|
387
418
|
<div class="method-source-code" id="groups-source">
|
388
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
419
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 146</span>
|
389
420
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">groups</span>(<span class="ruby-identifier">group_name</span>, <span class="ruby-identifier">options</span>={})
|
390
421
|
<span class="ruby-identifier">collection</span> = <span class="ruby-identifier">groups_search</span>({<span class="ruby-string">"text"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">group_name</span>}.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>))[<span class="ruby-string">'groups'</span>][<span class="ruby-string">'group'</span>]
|
391
422
|
<span class="ruby-identifier">collection</span> = [<span class="ruby-identifier">collection</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">collection</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
|
@@ -395,14 +426,14 @@ which made the request</p>
|
|
395
426
|
<span class="ruby-string">"eighteenplus"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">group</span>[<span class="ruby-string">'eighteenplus'</span>],
|
396
427
|
<span class="ruby-string">"client"</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">self</span>) }
|
397
428
|
<span class="ruby-keyword">end</span></pre>
|
398
|
-
</div
|
429
|
+
</div><!-- groups-source -->
|
399
430
|
|
400
431
|
</div>
|
401
432
|
|
402
433
|
|
403
434
|
|
404
435
|
|
405
|
-
</div
|
436
|
+
</div><!-- groups-method -->
|
406
437
|
|
407
438
|
|
408
439
|
<div id="method-i-http_get" class="method-detail ">
|
@@ -424,18 +455,25 @@ which made the request</p>
|
|
424
455
|
|
425
456
|
|
426
457
|
<div class="method-source-code" id="http_get-source">
|
427
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
458
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 184</span>
|
428
459
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">http_get</span>(<span class="ruby-identifier">url</span>)
|
429
|
-
<span class="ruby-
|
460
|
+
<span class="ruby-identifier">url</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">url</span>)
|
461
|
+
<span class="ruby-identifier">http</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">url</span>.<span class="ruby-identifier">host</span>, <span class="ruby-identifier">url</span>.<span class="ruby-identifier">port</span>
|
462
|
+
<span class="ruby-identifier">http</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword">true</span>
|
463
|
+
<span class="ruby-identifier">http</span>.<span class="ruby-identifier">verify_mode</span> = (<span class="ruby-ivar">@verify_ssl</span> <span class="ruby-operator">?</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_PEER</span> <span class="ruby-operator">:</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>)
|
464
|
+
<span class="ruby-identifier">http</span>.<span class="ruby-identifier">ca_file</span> = <span class="ruby-ivar">@ca_file</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@ca_file</span>
|
465
|
+
<span class="ruby-identifier">http</span>.<span class="ruby-identifier">start</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">res</span><span class="ruby-operator">|</span>
|
466
|
+
<span class="ruby-identifier">res</span>.<span class="ruby-identifier">request_get</span>(<span class="ruby-identifier">url</span>).<span class="ruby-identifier">body</span>.<span class="ruby-identifier">to_s</span>
|
467
|
+
<span class="ruby-keyword">end</span>
|
430
468
|
<span class="ruby-keyword">end</span></pre>
|
431
|
-
</div
|
469
|
+
</div><!-- http_get-source -->
|
432
470
|
|
433
471
|
</div>
|
434
472
|
|
435
473
|
|
436
474
|
|
437
475
|
|
438
|
-
</div
|
476
|
+
</div><!-- http_get-method -->
|
439
477
|
|
440
478
|
|
441
479
|
<div id="method-i-licenses" class="method-detail ">
|
@@ -457,18 +495,18 @@ which made the request</p>
|
|
457
495
|
|
458
496
|
|
459
497
|
<div class="method-source-code" id="licenses-source">
|
460
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
498
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 166</span>
|
461
499
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">licenses</span>
|
462
500
|
<span class="ruby-identifier">photos_licenses_getInfo</span>[<span class="ruby-string">'licenses'</span>][<span class="ruby-string">'license'</span>]
|
463
501
|
<span class="ruby-keyword">end</span></pre>
|
464
|
-
</div
|
502
|
+
</div><!-- licenses-source -->
|
465
503
|
|
466
504
|
</div>
|
467
505
|
|
468
506
|
|
469
507
|
|
470
508
|
|
471
|
-
</div
|
509
|
+
</div><!-- licenses-method -->
|
472
510
|
|
473
511
|
|
474
512
|
<div id="method-i-login_url" class="method-detail ">
|
@@ -491,18 +529,18 @@ authenticate app for a user</p>
|
|
491
529
|
|
492
530
|
|
493
531
|
<div class="method-source-code" id="login_url-source">
|
494
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
532
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 171</span>
|
495
533
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">login_url</span>(<span class="ruby-identifier">perms</span>)
|
496
|
-
<span class="ruby-node">"
|
534
|
+
<span class="ruby-node">"https://flickr.com/services/auth/?api_key=#{@api_key}&perms=#{perms}&api_sig=#{signature_from('api_key'=>@api_key, 'perms' => perms)}"</span>
|
497
535
|
<span class="ruby-keyword">end</span></pre>
|
498
|
-
</div
|
536
|
+
</div><!-- login_url-source -->
|
499
537
|
|
500
538
|
</div>
|
501
539
|
|
502
540
|
|
503
541
|
|
504
542
|
|
505
|
-
</div
|
543
|
+
</div><!-- login_url-method -->
|
506
544
|
|
507
545
|
|
508
546
|
<div id="method-i-method_missing" class="method-detail ">
|
@@ -527,18 +565,18 @@ will pass the call to the flickr.test.echo method.</p>
|
|
527
565
|
|
528
566
|
|
529
567
|
<div class="method-source-code" id="method_missing-source">
|
530
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
568
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 179</span>
|
531
569
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">method_id</span>, <span class="ruby-identifier">params</span>={})
|
532
570
|
<span class="ruby-identifier">request</span>(<span class="ruby-identifier">method_id</span>.<span class="ruby-identifier">id2name</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/_/</span>, <span class="ruby-string">'.'</span>), <span class="ruby-identifier">params</span>)
|
533
571
|
<span class="ruby-keyword">end</span></pre>
|
534
|
-
</div
|
572
|
+
</div><!-- method_missing-source -->
|
535
573
|
|
536
574
|
</div>
|
537
575
|
|
538
576
|
|
539
577
|
|
540
578
|
|
541
|
-
</div
|
579
|
+
</div><!-- method_missing-method -->
|
542
580
|
|
543
581
|
|
544
582
|
<div id="method-i-photos" class="method-detail ">
|
@@ -560,18 +598,18 @@ will pass the call to the flickr.test.echo method.</p>
|
|
560
598
|
|
561
599
|
|
562
600
|
<div class="method-source-code" id="photos-source">
|
563
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
601
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 119</span>
|
564
602
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">photos</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">criteria</span>)
|
565
603
|
<span class="ruby-keyword">not</span> <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">photos_search</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">criteria</span>) <span class="ruby-keyword">or</span> <span class="ruby-identifier">recent</span>
|
566
604
|
<span class="ruby-keyword">end</span></pre>
|
567
|
-
</div
|
605
|
+
</div><!-- photos-source -->
|
568
606
|
|
569
607
|
</div>
|
570
608
|
|
571
609
|
|
572
610
|
|
573
611
|
|
574
|
-
</div
|
612
|
+
</div><!-- photos-method -->
|
575
613
|
|
576
614
|
|
577
615
|
<div id="method-i-photos_request" class="method-detail ">
|
@@ -595,19 +633,19 @@ href="Flickr/Photo.html">Photo</a> objects)</p>
|
|
595
633
|
|
596
634
|
|
597
635
|
<div class="method-source-code" id="photos_request-source">
|
598
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
636
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 204</span>
|
599
637
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">photos_request</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">params</span>={}, <span class="ruby-identifier">list_node</span>=<span class="ruby-string">"photos"</span>)
|
600
638
|
<span class="ruby-identifier">photos</span> = <span class="ruby-identifier">request</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">params</span>)
|
601
639
|
<span class="ruby-constant">PhotoCollection</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">photos</span>, <span class="ruby-ivar">@api_key</span>, <span class="ruby-identifier">list_node</span>)
|
602
640
|
<span class="ruby-keyword">end</span></pre>
|
603
|
-
</div
|
641
|
+
</div><!-- photos_request-source -->
|
604
642
|
|
605
643
|
</div>
|
606
644
|
|
607
645
|
|
608
646
|
|
609
647
|
|
610
|
-
</div
|
648
|
+
</div><!-- photos_request-method -->
|
611
649
|
|
612
650
|
|
613
651
|
<div id="method-i-photos_search" class="method-detail ">
|
@@ -629,11 +667,11 @@ href="Flickr/Photo.html">Photo</a> objects)</p>
|
|
629
667
|
|
630
668
|
|
631
669
|
<div class="method-source-code" id="photos_search-source">
|
632
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
670
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 129</span>
|
633
671
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">photos_search</span>(<span class="ruby-identifier">params</span>={})
|
634
672
|
<span class="ruby-identifier">photos_request</span>(<span class="ruby-string">'photos.search'</span>, <span class="ruby-identifier">params</span>)
|
635
673
|
<span class="ruby-keyword">end</span></pre>
|
636
|
-
</div
|
674
|
+
</div><!-- photos_search-source -->
|
637
675
|
|
638
676
|
</div>
|
639
677
|
|
@@ -644,7 +682,7 @@ href="Flickr/Photo.html">Photo</a> objects)</p>
|
|
644
682
|
|
645
683
|
|
646
684
|
|
647
|
-
</div
|
685
|
+
</div><!-- photos_search-method -->
|
648
686
|
|
649
687
|
|
650
688
|
<div id="method-i-photoset" class="method-detail ">
|
@@ -666,18 +704,18 @@ href="Flickr/Photo.html">Photo</a> objects)</p>
|
|
666
704
|
|
667
705
|
|
668
706
|
<div class="method-source-code" id="photoset-source">
|
669
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
707
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 156</span>
|
670
708
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">photoset</span>(<span class="ruby-identifier">photoset_id</span>)
|
671
709
|
<span class="ruby-constant">Photoset</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">photoset_id</span>, <span class="ruby-ivar">@api_key</span>)
|
672
710
|
<span class="ruby-keyword">end</span></pre>
|
673
|
-
</div
|
711
|
+
</div><!-- photoset-source -->
|
674
712
|
|
675
713
|
</div>
|
676
714
|
|
677
715
|
|
678
716
|
|
679
717
|
|
680
|
-
</div
|
718
|
+
</div><!-- photoset-method -->
|
681
719
|
|
682
720
|
|
683
721
|
<div id="method-i-recent" class="method-detail ">
|
@@ -699,18 +737,18 @@ href="Flickr/Photo.html">Photo</a> objects)</p>
|
|
699
737
|
|
700
738
|
|
701
739
|
<div class="method-source-code" id="recent-source">
|
702
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
740
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 125</span>
|
703
741
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">recent</span>
|
704
742
|
<span class="ruby-identifier">photos_request</span>(<span class="ruby-string">'photos.getRecent'</span>)
|
705
743
|
<span class="ruby-keyword">end</span></pre>
|
706
|
-
</div
|
744
|
+
</div><!-- recent-source -->
|
707
745
|
|
708
746
|
</div>
|
709
747
|
|
710
748
|
|
711
749
|
|
712
750
|
|
713
|
-
</div
|
751
|
+
</div><!-- recent-method -->
|
714
752
|
|
715
753
|
|
716
754
|
<div id="method-i-related_tags" class="method-detail ">
|
@@ -732,18 +770,18 @@ href="Flickr/Photo.html">Photo</a> objects)</p>
|
|
732
770
|
|
733
771
|
|
734
772
|
<div class="method-source-code" id="related_tags-source">
|
735
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
773
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 161</span>
|
736
774
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">related_tags</span>(<span class="ruby-identifier">tag</span>)
|
737
775
|
<span class="ruby-identifier">tags_getRelated</span>(<span class="ruby-string">'tag'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">tag</span>)[<span class="ruby-string">'tags'</span>][<span class="ruby-string">'tag'</span>]
|
738
776
|
<span class="ruby-keyword">end</span></pre>
|
739
|
-
</div
|
777
|
+
</div><!-- related_tags-source -->
|
740
778
|
|
741
779
|
</div>
|
742
780
|
|
743
781
|
|
744
782
|
|
745
783
|
|
746
|
-
</div
|
784
|
+
</div><!-- related_tags-method -->
|
747
785
|
|
748
786
|
|
749
787
|
<div id="method-i-request" class="method-detail ">
|
@@ -766,21 +804,21 @@ parameters; returns an XmlSimple object with the response</p>
|
|
766
804
|
|
767
805
|
|
768
806
|
<div class="method-source-code" id="request-source">
|
769
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
807
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 196</span>
|
770
808
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">request</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">params</span>={})
|
771
809
|
<span class="ruby-identifier">url</span> = <span class="ruby-identifier">request_url</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">params</span>)
|
772
810
|
<span class="ruby-identifier">response</span> = <span class="ruby-constant">XmlSimple</span>.<span class="ruby-identifier">xml_in</span>(<span class="ruby-identifier">http_get</span>(<span class="ruby-identifier">url</span>), { <span class="ruby-string">'ForceArray'</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">false</span> })
|
773
811
|
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">response</span>[<span class="ruby-string">'err'</span>][<span class="ruby-string">'msg'</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">response</span>[<span class="ruby-string">'stat'</span>] <span class="ruby-operator">!=</span> <span class="ruby-string">'ok'</span>
|
774
812
|
<span class="ruby-identifier">response</span>
|
775
813
|
<span class="ruby-keyword">end</span></pre>
|
776
|
-
</div
|
814
|
+
</div><!-- request-source -->
|
777
815
|
|
778
816
|
</div>
|
779
817
|
|
780
818
|
|
781
819
|
|
782
820
|
|
783
|
-
</div
|
821
|
+
</div><!-- request-method -->
|
784
822
|
|
785
823
|
|
786
824
|
<div id="method-i-request_url" class="method-detail ">
|
@@ -805,7 +843,7 @@ Hash (e.g 'user_id' => “foo123”)</p>
|
|
805
843
|
|
806
844
|
|
807
845
|
<div class="method-source-code" id="request_url-source">
|
808
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
846
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 212</span>
|
809
847
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">request_url</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">params</span>={})
|
810
848
|
<span class="ruby-identifier">method</span> = <span class="ruby-string">'flickr.'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">method</span>
|
811
849
|
<span class="ruby-identifier">url</span> = <span class="ruby-node">"#{@host}#{@api}/?api_key=#{@api_key}&method=#{method}"</span>
|
@@ -814,14 +852,14 @@ Hash (e.g 'user_id' => “foo123”)</p>
|
|
814
852
|
|
815
853
|
<span class="ruby-identifier">url</span> = <span class="ruby-node">"#{@host}#{@api}/?"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-string">'api_sig'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">signature</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-node">"#{k}="</span> <span class="ruby-operator">+</span> <span class="ruby-constant">CGI</span><span class="ruby-operator">::</span><span class="ruby-identifier">escape</span>(<span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">nil?</span> }.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">"&"</span>)
|
816
854
|
<span class="ruby-keyword">end</span></pre>
|
817
|
-
</div
|
855
|
+
</div><!-- request_url-source -->
|
818
856
|
|
819
857
|
</div>
|
820
858
|
|
821
859
|
|
822
860
|
|
823
861
|
|
824
|
-
</div
|
862
|
+
</div><!-- request_url-method -->
|
825
863
|
|
826
864
|
|
827
865
|
<div id="method-i-search" class="method-detail method-alias">
|
@@ -849,7 +887,7 @@ Hash (e.g 'user_id' => “foo123”)</p>
|
|
849
887
|
Alias for: <a href="Flickr.html#method-i-photos_search">photos_search</a>
|
850
888
|
</div>
|
851
889
|
|
852
|
-
</div
|
890
|
+
</div><!-- search-method -->
|
853
891
|
|
854
892
|
|
855
893
|
<div id="method-i-set_up_configuration" class="method-detail ">
|
@@ -871,20 +909,22 @@ Hash (e.g 'user_id' => “foo123”)</p>
|
|
871
909
|
|
872
910
|
|
873
911
|
<div class="method-source-code" id="set_up_configuration-source">
|
874
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
912
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 91</span>
|
875
913
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">set_up_configuration</span> <span class="ruby-identifier">api_key_or_params</span> = {}
|
876
914
|
<span class="ruby-ivar">@api_key</span> = <span class="ruby-identifier">api_key_or_params</span>[<span class="ruby-value">:api_key</span>]
|
877
915
|
<span class="ruby-ivar">@shared_secret</span> = <span class="ruby-identifier">api_key_or_params</span>[<span class="ruby-value">:shared_secret</span>]
|
878
916
|
<span class="ruby-ivar">@auth_token</span> = <span class="ruby-identifier">api_key_or_params</span>[<span class="ruby-value">:auth_token</span>]
|
917
|
+
<span class="ruby-ivar">@ca_file</span> = <span class="ruby-identifier">api_key_or_params</span>[<span class="ruby-value">:ca_file</span>]
|
918
|
+
<span class="ruby-ivar">@verify_ssl</span> = <span class="ruby-operator">!</span>(<span class="ruby-identifier">api_key_or_params</span>[<span class="ruby-value">:verify_ssl</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-operator">===</span> <span class="ruby-string">'false'</span>)
|
879
919
|
<span class="ruby-keyword">end</span></pre>
|
880
|
-
</div
|
920
|
+
</div><!-- set_up_configuration-source -->
|
881
921
|
|
882
922
|
</div>
|
883
923
|
|
884
924
|
|
885
925
|
|
886
926
|
|
887
|
-
</div
|
927
|
+
</div><!-- set_up_configuration-method -->
|
888
928
|
|
889
929
|
|
890
930
|
<div id="method-i-signature_from" class="method-detail ">
|
@@ -906,20 +946,20 @@ Hash (e.g 'user_id' => “foo123”)</p>
|
|
906
946
|
|
907
947
|
|
908
948
|
<div class="method-source-code" id="signature_from-source">
|
909
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
949
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 221</span>
|
910
950
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">signature_from</span>(<span class="ruby-identifier">params</span>={})
|
911
951
|
<span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@shared_secret</span> <span class="ruby-comment"># don't both getting signature if no shared_secret</span>
|
912
952
|
<span class="ruby-identifier">request_str</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">reject</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">nil?</span>}.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-node">"#{p[0].to_s}#{p[1]}"</span>}.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">join</span> <span class="ruby-comment"># build key value pairs, sort in alpha order then join them, ignoring those with nil value</span>
|
913
953
|
<span class="ruby-keyword">return</span> <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">MD5</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-node">"#{@shared_secret}#{request_str}"</span>)
|
914
954
|
<span class="ruby-keyword">end</span></pre>
|
915
|
-
</div
|
955
|
+
</div><!-- signature_from-source -->
|
916
956
|
|
917
957
|
</div>
|
918
958
|
|
919
959
|
|
920
960
|
|
921
961
|
|
922
|
-
</div
|
962
|
+
</div><!-- signature_from-method -->
|
923
963
|
|
924
964
|
|
925
965
|
<div id="method-i-tag" class="method-detail ">
|
@@ -941,18 +981,18 @@ Hash (e.g 'user_id' => “foo123”)</p>
|
|
941
981
|
|
942
982
|
|
943
983
|
<div class="method-source-code" id="tag-source">
|
944
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
984
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 135</span>
|
945
985
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">tag</span>(<span class="ruby-identifier">tag</span>)
|
946
986
|
<span class="ruby-identifier">photos</span>(<span class="ruby-string">'tags'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">tag</span>)
|
947
987
|
<span class="ruby-keyword">end</span></pre>
|
948
|
-
</div
|
988
|
+
</div><!-- tag-source -->
|
949
989
|
|
950
990
|
</div>
|
951
991
|
|
952
992
|
|
953
993
|
|
954
994
|
|
955
|
-
</div
|
995
|
+
</div><!-- tag-method -->
|
956
996
|
|
957
997
|
|
958
998
|
<div id="method-i-users" class="method-detail ">
|
@@ -974,30 +1014,31 @@ Hash (e.g 'user_id' => “foo123”)</p>
|
|
974
1014
|
|
975
1015
|
|
976
1016
|
<div class="method-source-code" id="users-source">
|
977
|
-
<pre><span class="ruby-comment"># File lib/flickr.rb, line
|
1017
|
+
<pre><span class="ruby-comment"># File lib/flickr.rb, line 140</span>
|
978
1018
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">users</span>(<span class="ruby-identifier">lookup</span>=<span class="ruby-keyword">nil</span>)
|
979
1019
|
<span class="ruby-identifier">user</span> = <span class="ruby-identifier">people_findByEmail</span>(<span class="ruby-string">'find_email'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">lookup</span>)[<span class="ruby-string">'user'</span>] <span class="ruby-keyword">rescue</span> <span class="ruby-identifier">people_findByUsername</span>(<span class="ruby-string">'username'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">lookup</span>)[<span class="ruby-string">'user'</span>]
|
980
1020
|
<span class="ruby-keyword">return</span> <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">"id"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">user</span>[<span class="ruby-string">"nsid"</span>], <span class="ruby-string">"username"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">user</span>[<span class="ruby-string">"username"</span>], <span class="ruby-string">"client"</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">self</span>)
|
981
1021
|
<span class="ruby-keyword">end</span></pre>
|
982
|
-
</div
|
1022
|
+
</div><!-- users-source -->
|
983
1023
|
|
984
1024
|
</div>
|
985
1025
|
|
986
1026
|
|
987
1027
|
|
988
1028
|
|
989
|
-
</div
|
1029
|
+
</div><!-- users-method -->
|
990
1030
|
|
991
1031
|
|
992
|
-
</section
|
1032
|
+
</section><!-- public-instance-method-details -->
|
993
1033
|
|
994
|
-
</section
|
995
|
-
|
1034
|
+
</section><!-- 5Buntitled-5D -->
|
1035
|
+
|
1036
|
+
</div><!-- documentation -->
|
996
1037
|
|
997
1038
|
|
998
|
-
<footer id="validator-badges"
|
999
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
1000
|
-
<p>Generated by <a href="
|
1001
|
-
<p>
|
1039
|
+
<footer id="validator-badges">
|
1040
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
1041
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
1042
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
1002
1043
|
</footer>
|
1003
1044
|
|