flickr.rb 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.txt +70 -0
- data/LICENSE +20 -0
- data/Manifest.txt +10 -0
- data/README.txt +90 -0
- data/Rakefile +49 -0
- data/TODO +6 -0
- data/flickr.gemspec +30 -0
- data/init.rb +7 -0
- data/lib/flickr.rb +734 -0
- data/rdoc/classes/Flickr.html +807 -0
- data/rdoc/classes/Flickr/Config.html +240 -0
- data/rdoc/classes/Flickr/Group.html +251 -0
- data/rdoc/classes/Flickr/Photo.html +1101 -0
- data/rdoc/classes/Flickr/PhotoCollection.html +194 -0
- data/rdoc/classes/Flickr/Photoset.html +266 -0
- data/rdoc/classes/Flickr/User.html +738 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/README_txt.html +209 -0
- data/rdoc/files/lib/flickr_rb.html +162 -0
- data/rdoc/fr_class_index.html +33 -0
- data/rdoc/fr_file_index.html +28 -0
- data/rdoc/fr_method_index.html +112 -0
- data/rdoc/index.html +24 -0
- data/rdoc/rdoc-style.css +208 -0
- data/test/flickr_test.rb +1112 -0
- metadata +99 -0
@@ -0,0 +1,807 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Flickr</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Flickr</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/flickr_rb.html">
|
59
|
+
lib/flickr.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
<a href="Flickr.html">Flickr</a> client class. Requires an API key
|
84
|
+
</p>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<div id="method-list">
|
92
|
+
<h3 class="section-bar">Methods</h3>
|
93
|
+
|
94
|
+
<div class="name-list">
|
95
|
+
<a href="#M000004">find_by_url</a>
|
96
|
+
<a href="#M000003">get_token_from</a>
|
97
|
+
<a href="#M000011">groups</a>
|
98
|
+
<a href="#M000017">http_get</a>
|
99
|
+
<a href="#M000014">licenses</a>
|
100
|
+
<a href="#M000015">login_url</a>
|
101
|
+
<a href="#M000016">method_missing</a>
|
102
|
+
<a href="#M000001">new</a>
|
103
|
+
<a href="#M000005">photos</a>
|
104
|
+
<a href="#M000019">photos_request</a>
|
105
|
+
<a href="#M000007">photos_search</a>
|
106
|
+
<a href="#M000012">photoset</a>
|
107
|
+
<a href="#M000006">recent</a>
|
108
|
+
<a href="#M000013">related_tags</a>
|
109
|
+
<a href="#M000018">request</a>
|
110
|
+
<a href="#M000020">request_url</a>
|
111
|
+
<a href="#M000008">search</a>
|
112
|
+
<a href="#M000002">set_up_configuration</a>
|
113
|
+
<a href="#M000021">signature_from</a>
|
114
|
+
<a href="#M000009">tag</a>
|
115
|
+
<a href="#M000010">users</a>
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
|
122
|
+
<!-- if includes -->
|
123
|
+
|
124
|
+
<div id="section">
|
125
|
+
|
126
|
+
<div id="class-list">
|
127
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
128
|
+
|
129
|
+
Class <a href="Flickr/Config.html" class="link">Flickr::Config</a><br />
|
130
|
+
Class <a href="Flickr/Group.html" class="link">Flickr::Group</a><br />
|
131
|
+
Class <a href="Flickr/Photo.html" class="link">Flickr::Photo</a><br />
|
132
|
+
Class <a href="Flickr/PhotoCollection.html" class="link">Flickr::PhotoCollection</a><br />
|
133
|
+
Class <a href="Flickr/Photoset.html" class="link">Flickr::Photoset</a><br />
|
134
|
+
Class <a href="Flickr/User.html" class="link">Flickr::User</a><br />
|
135
|
+
|
136
|
+
</div>
|
137
|
+
|
138
|
+
<div id="constants-list">
|
139
|
+
<h3 class="section-bar">Constants</h3>
|
140
|
+
|
141
|
+
<div class="name-list">
|
142
|
+
<table summary="Constants">
|
143
|
+
<tr class="top-aligned-row context-row">
|
144
|
+
<td class="context-item-name">HOST_URL</td>
|
145
|
+
<td>=</td>
|
146
|
+
<td class="context-item-value">'http://api.flickr.com'</td>
|
147
|
+
</tr>
|
148
|
+
<tr class="top-aligned-row context-row">
|
149
|
+
<td class="context-item-name">API_PATH</td>
|
150
|
+
<td>=</td>
|
151
|
+
<td class="context-item-value">'/services/rest'</td>
|
152
|
+
</tr>
|
153
|
+
<tr class="top-aligned-row context-row">
|
154
|
+
<td class="context-item-name">VALID_SIZES</td>
|
155
|
+
<td>=</td>
|
156
|
+
<td class="context-item-value">{ "Square" => ["s", "sq"], "Thumbnail" => ["t", "t"], "Small" => ["m", "s"], "Medium" => [nil, "m"], "Large" => ["b", "l"]</td>
|
157
|
+
<td width="3em"> </td>
|
158
|
+
<td class="context-item-desc">
|
159
|
+
<a href="Flickr.html">Flickr</a>, annoyingly, uses a number of
|
160
|
+
representations to specify the size of a photo, depending on the context.
|
161
|
+
It gives a label such a "Small" or "Medium" to a size
|
162
|
+
of photo, when returning all possible sizes. However, when generating the
|
163
|
+
uri for the page that features that size of photo, or the source url for
|
164
|
+
the image itself it uses a single letter. Bizarrely, these letters are
|
165
|
+
different depending on whether you want the <a
|
166
|
+
href="Flickr.html">Flickr</a> page for the photo or the source uri —
|
167
|
+
e.g. a "Small" photo (240 pixels on its longest side) may be
|
168
|
+
viewed at "<a
|
169
|
+
href="http://www.flickr.com/photos/sco/2397458775/sizes/s">www.flickr.com/photos/sco/2397458775/sizes/s</a>/"
|
170
|
+
but its source is at "<img
|
171
|
+
src="http://farm4.static.flickr.com/3118/2397458775_2ec2ddc324_m.jpg"
|
172
|
+
/>". The VALID_SIZES hash associates the correct letter with a label
|
173
|
+
|
174
|
+
</td>
|
175
|
+
</tr>
|
176
|
+
</table>
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
<div id="attribute-list">
|
183
|
+
<h3 class="section-bar">Attributes</h3>
|
184
|
+
|
185
|
+
<div class="name-list">
|
186
|
+
<table>
|
187
|
+
<tr class="top-aligned-row context-row">
|
188
|
+
<td class="context-item-name">api_key</td>
|
189
|
+
<td class="context-item-value"> [R] </td>
|
190
|
+
<td class="context-item-desc"></td>
|
191
|
+
</tr>
|
192
|
+
<tr class="top-aligned-row context-row">
|
193
|
+
<td class="context-item-name">auth_token</td>
|
194
|
+
<td class="context-item-value"> [R] </td>
|
195
|
+
<td class="context-item-desc"></td>
|
196
|
+
</tr>
|
197
|
+
<tr class="top-aligned-row context-row">
|
198
|
+
<td class="context-item-name">user</td>
|
199
|
+
<td class="context-item-value"> [RW] </td>
|
200
|
+
<td class="context-item-desc"></td>
|
201
|
+
</tr>
|
202
|
+
</table>
|
203
|
+
</div>
|
204
|
+
</div>
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
<!-- if method_list -->
|
209
|
+
<div id="methods">
|
210
|
+
<h3 class="section-bar">Public Class methods</h3>
|
211
|
+
|
212
|
+
<div id="method-M000001" class="method-detail">
|
213
|
+
<a name="M000001"></a>
|
214
|
+
|
215
|
+
<div class="method-heading">
|
216
|
+
<a href="#M000001" class="method-signature">
|
217
|
+
<span class="method-name">new</span><span class="method-args">(api_key_or_params={})</span>
|
218
|
+
</a>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
<div class="method-description">
|
222
|
+
<p>
|
223
|
+
To use the <a href="Flickr.html">Flickr</a> API you need an api key (see <a
|
224
|
+
href="http://www.flickr.com/services/api/misc.api_keys.html">www.flickr.com/services/api/misc.api_keys.html</a>),
|
225
|
+
and the flickr client object shuld be initialized with this. You‘ll
|
226
|
+
also need a shared secret code if you want to use authentication (e.g. to
|
227
|
+
get a user‘s private <a href="Flickr.html#M000005">photos</a>) There
|
228
|
+
are two ways to initialize the <a href="Flickr.html">Flickr</a> client. The
|
229
|
+
preferred way is with a hash of params, e.g. ‘api_key’ =>
|
230
|
+
‘your_api_key’, ‘shared_secret’ =>
|
231
|
+
‘shared_secret_code’. Other way is to use in Rails an config
|
232
|
+
file RAILS_ROOT/config/flickr.api.yml and there use params as key/values
|
233
|
+
even specified for every environment.
|
234
|
+
</p>
|
235
|
+
<p><a class="source-toggle" href="#"
|
236
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
237
|
+
<div class="method-source-code" id="M000001-source">
|
238
|
+
<pre>
|
239
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 78</span>
|
240
|
+
78: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">api_key_or_params</span>={})
|
241
|
+
79: <span class="ruby-ivar">@host</span> = <span class="ruby-constant">HOST_URL</span>
|
242
|
+
80: <span class="ruby-ivar">@api</span> = <span class="ruby-constant">API_PATH</span>
|
243
|
+
81: <span class="ruby-identifier">api_key_or_params</span>={} <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">api_key_or_params</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-comment cmt"># fix for nil value as argument</span>
|
244
|
+
82: <span class="ruby-identifier">api_key_or_params</span> = {<span class="ruby-identifier">:api_key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">api_key_or_params</span>} <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">api_key_or_params</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
|
245
|
+
83: <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 kw">if</span> <span class="ruby-constant">Config</span>.<span class="ruby-identifier">parsed?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">api_key_or_params</span>.<span class="ruby-identifier">empty?</span>
|
246
|
+
84: <span class="ruby-identifier">set_up_configuration</span> <span class="ruby-identifier">api_key_or_params</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">api_key_or_params</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
|
247
|
+
85: <span class="ruby-keyword kw">end</span>
|
248
|
+
</pre>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
</div>
|
252
|
+
|
253
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
254
|
+
|
255
|
+
<div id="method-M000004" class="method-detail">
|
256
|
+
<a name="M000004"></a>
|
257
|
+
|
258
|
+
<div class="method-heading">
|
259
|
+
<a href="#M000004" class="method-signature">
|
260
|
+
<span class="method-name">find_by_url</span><span class="method-args">(url)</span>
|
261
|
+
</a>
|
262
|
+
</div>
|
263
|
+
|
264
|
+
<div class="method-description">
|
265
|
+
<p>
|
266
|
+
Implements flickr.urls.lookupGroup and flickr.urls.lookupUser
|
267
|
+
</p>
|
268
|
+
<p><a class="source-toggle" href="#"
|
269
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
270
|
+
<div class="method-source-code" id="M000004-source">
|
271
|
+
<pre>
|
272
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 107</span>
|
273
|
+
107: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_by_url</span>(<span class="ruby-identifier">url</span>)
|
274
|
+
108: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">urls_lookupUser</span>(<span class="ruby-value str">'url'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">url</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-identifier">urls_lookupGroup</span>(<span class="ruby-value str">'url'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">url</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
275
|
+
109: (<span class="ruby-identifier">response</span>[<span class="ruby-value str">'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-value str">'user'</span>][<span class="ruby-value str">'id'</span>], <span class="ruby-keyword kw">nil</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-keyword kw">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-value str">'group'</span>][<span class="ruby-value str">'id'</span>], <span class="ruby-ivar">@api_key</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">nil?</span>
|
276
|
+
110: <span class="ruby-keyword kw">end</span>
|
277
|
+
</pre>
|
278
|
+
</div>
|
279
|
+
</div>
|
280
|
+
</div>
|
281
|
+
|
282
|
+
<div id="method-M000003" class="method-detail">
|
283
|
+
<a name="M000003"></a>
|
284
|
+
|
285
|
+
<div class="method-heading">
|
286
|
+
<a href="#M000003" class="method-signature">
|
287
|
+
<span class="method-name">get_token_from</span><span class="method-args">(frob)</span>
|
288
|
+
</a>
|
289
|
+
</div>
|
290
|
+
|
291
|
+
<div class="method-description">
|
292
|
+
<p>
|
293
|
+
Gets authentication token given a <a href="Flickr.html">Flickr</a> frob,
|
294
|
+
which is returned when user allows access to their account for the
|
295
|
+
application with the api_key which made the <a
|
296
|
+
href="Flickr.html#M000018">request</a>
|
297
|
+
</p>
|
298
|
+
<p><a class="source-toggle" href="#"
|
299
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
300
|
+
<div class="method-source-code" id="M000003-source">
|
301
|
+
<pre>
|
302
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 96</span>
|
303
|
+
96: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_token_from</span>(<span class="ruby-identifier">frob</span>)
|
304
|
+
97: <span class="ruby-identifier">auth_response</span> = <span class="ruby-identifier">request</span>(<span class="ruby-value str">"auth.getToken"</span>, <span class="ruby-identifier">:frob</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">frob</span>)[<span class="ruby-value str">'auth'</span>]
|
305
|
+
98: <span class="ruby-ivar">@auth_token</span> = <span class="ruby-identifier">auth_response</span>[<span class="ruby-value str">'token'</span>]
|
306
|
+
99: <span class="ruby-ivar">@user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value str">'id'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">auth_response</span>[<span class="ruby-value str">'user'</span>][<span class="ruby-value str">'nsid'</span>],
|
307
|
+
100: <span class="ruby-value str">'username'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">auth_response</span>[<span class="ruby-value str">'user'</span>][<span class="ruby-value str">'username'</span>],
|
308
|
+
101: <span class="ruby-value str">'name'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">auth_response</span>[<span class="ruby-value str">'user'</span>][<span class="ruby-value str">'fullname'</span>],
|
309
|
+
102: <span class="ruby-value str">'client'</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>)
|
310
|
+
103: <span class="ruby-ivar">@auth_token</span>
|
311
|
+
104: <span class="ruby-keyword kw">end</span>
|
312
|
+
</pre>
|
313
|
+
</div>
|
314
|
+
</div>
|
315
|
+
</div>
|
316
|
+
|
317
|
+
<div id="method-M000011" class="method-detail">
|
318
|
+
<a name="M000011"></a>
|
319
|
+
|
320
|
+
<div class="method-heading">
|
321
|
+
<a href="#M000011" class="method-signature">
|
322
|
+
<span class="method-name">groups</span><span class="method-args">(group_name, options={})</span>
|
323
|
+
</a>
|
324
|
+
</div>
|
325
|
+
|
326
|
+
<div class="method-description">
|
327
|
+
<p>
|
328
|
+
Implements flickr.groups.<a href="Flickr.html#M000008">search</a>
|
329
|
+
</p>
|
330
|
+
<p><a class="source-toggle" href="#"
|
331
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
332
|
+
<div class="method-source-code" id="M000011-source">
|
333
|
+
<pre>
|
334
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 140</span>
|
335
|
+
140: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">groups</span>(<span class="ruby-identifier">group_name</span>, <span class="ruby-identifier">options</span>={})
|
336
|
+
141: <span class="ruby-identifier">collection</span> = <span class="ruby-identifier">groups_search</span>({<span class="ruby-value str">"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-value str">'groups'</span>][<span class="ruby-value str">'group'</span>]
|
337
|
+
142: <span class="ruby-identifier">collection</span> = [<span class="ruby-identifier">collection</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">collection</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
|
338
|
+
143:
|
339
|
+
144: <span class="ruby-identifier">collection</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">group</span><span class="ruby-operator">|</span> <span class="ruby-constant">Group</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value str">"id"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">group</span>[<span class="ruby-value str">'nsid'</span>],
|
340
|
+
145: <span class="ruby-value str">"name"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">group</span>[<span class="ruby-value str">'name'</span>],
|
341
|
+
146: <span class="ruby-value str">"eighteenplus"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">group</span>[<span class="ruby-value str">'eighteenplus'</span>],
|
342
|
+
147: <span class="ruby-value str">"client"</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>) }
|
343
|
+
148: <span class="ruby-keyword kw">end</span>
|
344
|
+
</pre>
|
345
|
+
</div>
|
346
|
+
</div>
|
347
|
+
</div>
|
348
|
+
|
349
|
+
<div id="method-M000017" class="method-detail">
|
350
|
+
<a name="M000017"></a>
|
351
|
+
|
352
|
+
<div class="method-heading">
|
353
|
+
<a href="#M000017" class="method-signature">
|
354
|
+
<span class="method-name">http_get</span><span class="method-args">(url)</span>
|
355
|
+
</a>
|
356
|
+
</div>
|
357
|
+
|
358
|
+
<div class="method-description">
|
359
|
+
<p>
|
360
|
+
Does an HTTP GET on a given URL and returns the response body
|
361
|
+
</p>
|
362
|
+
<p><a class="source-toggle" href="#"
|
363
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
364
|
+
<div class="method-source-code" id="M000017-source">
|
365
|
+
<pre>
|
366
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 178</span>
|
367
|
+
178: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">http_get</span>(<span class="ruby-identifier">url</span>)
|
368
|
+
179: <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">url</span>)).<span class="ruby-identifier">body</span>.<span class="ruby-identifier">to_s</span>
|
369
|
+
180: <span class="ruby-keyword kw">end</span>
|
370
|
+
</pre>
|
371
|
+
</div>
|
372
|
+
</div>
|
373
|
+
</div>
|
374
|
+
|
375
|
+
<div id="method-M000014" class="method-detail">
|
376
|
+
<a name="M000014"></a>
|
377
|
+
|
378
|
+
<div class="method-heading">
|
379
|
+
<a href="#M000014" class="method-signature">
|
380
|
+
<span class="method-name">licenses</span><span class="method-args">()</span>
|
381
|
+
</a>
|
382
|
+
</div>
|
383
|
+
|
384
|
+
<div class="method-description">
|
385
|
+
<p>
|
386
|
+
Implements flickr.photos.licenses.getInfo
|
387
|
+
</p>
|
388
|
+
<p><a class="source-toggle" href="#"
|
389
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
390
|
+
<div class="method-source-code" id="M000014-source">
|
391
|
+
<pre>
|
392
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 160</span>
|
393
|
+
160: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">licenses</span>
|
394
|
+
161: <span class="ruby-identifier">photos_licenses_getInfo</span>[<span class="ruby-value str">'licenses'</span>][<span class="ruby-value str">'license'</span>]
|
395
|
+
162: <span class="ruby-keyword kw">end</span>
|
396
|
+
</pre>
|
397
|
+
</div>
|
398
|
+
</div>
|
399
|
+
</div>
|
400
|
+
|
401
|
+
<div id="method-M000015" class="method-detail">
|
402
|
+
<a name="M000015"></a>
|
403
|
+
|
404
|
+
<div class="method-heading">
|
405
|
+
<a href="#M000015" class="method-signature">
|
406
|
+
<span class="method-name">login_url</span><span class="method-args">(perms)</span>
|
407
|
+
</a>
|
408
|
+
</div>
|
409
|
+
|
410
|
+
<div class="method-description">
|
411
|
+
<p>
|
412
|
+
Returns url for user to login in to <a href="Flickr.html">Flickr</a> to
|
413
|
+
authenticate app for a user
|
414
|
+
</p>
|
415
|
+
<p><a class="source-toggle" href="#"
|
416
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
417
|
+
<div class="method-source-code" id="M000015-source">
|
418
|
+
<pre>
|
419
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 165</span>
|
420
|
+
165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">login_url</span>(<span class="ruby-identifier">perms</span>)
|
421
|
+
166: <span class="ruby-node">"http://flickr.com/services/auth/?api_key=#{@api_key}&perms=#{perms}&api_sig=#{signature_from('api_key'=>@api_key, 'perms' => perms)}"</span>
|
422
|
+
167: <span class="ruby-keyword kw">end</span>
|
423
|
+
</pre>
|
424
|
+
</div>
|
425
|
+
</div>
|
426
|
+
</div>
|
427
|
+
|
428
|
+
<div id="method-M000016" class="method-detail">
|
429
|
+
<a name="M000016"></a>
|
430
|
+
|
431
|
+
<div class="method-heading">
|
432
|
+
<a href="#M000016" class="method-signature">
|
433
|
+
<span class="method-name">method_missing</span><span class="method-args">(method_id, params={})</span>
|
434
|
+
</a>
|
435
|
+
</div>
|
436
|
+
|
437
|
+
<div class="method-description">
|
438
|
+
<p>
|
439
|
+
Implements everything else. Any method not defined explicitly will be
|
440
|
+
passed on to the <a href="Flickr.html">Flickr</a> API, and return an
|
441
|
+
XmlSimple document. For example, Flickr#test_echo is not defined, so it
|
442
|
+
will pass the call to the flickr.test.echo method.
|
443
|
+
</p>
|
444
|
+
<p><a class="source-toggle" href="#"
|
445
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
446
|
+
<div class="method-source-code" id="M000016-source">
|
447
|
+
<pre>
|
448
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 173</span>
|
449
|
+
173: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">method_id</span>, <span class="ruby-identifier">params</span>={})
|
450
|
+
174: <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 re">/_/</span>, <span class="ruby-value str">'.'</span>), <span class="ruby-identifier">params</span>)
|
451
|
+
175: <span class="ruby-keyword kw">end</span>
|
452
|
+
</pre>
|
453
|
+
</div>
|
454
|
+
</div>
|
455
|
+
</div>
|
456
|
+
|
457
|
+
<div id="method-M000005" class="method-detail">
|
458
|
+
<a name="M000005"></a>
|
459
|
+
|
460
|
+
<div class="method-heading">
|
461
|
+
<a href="#M000005" class="method-signature">
|
462
|
+
<span class="method-name">photos</span><span class="method-args">(*criteria)</span>
|
463
|
+
</a>
|
464
|
+
</div>
|
465
|
+
|
466
|
+
<div class="method-description">
|
467
|
+
<p>
|
468
|
+
Implements flickr.photos.getRecent and flickr.photos.<a
|
469
|
+
href="Flickr.html#M000008">search</a>
|
470
|
+
</p>
|
471
|
+
<p><a class="source-toggle" href="#"
|
472
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
473
|
+
<div class="method-source-code" id="M000005-source">
|
474
|
+
<pre>
|
475
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 113</span>
|
476
|
+
113: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">photos</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">criteria</span>)
|
477
|
+
114: <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">photos_search</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">criteria</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">recent</span>
|
478
|
+
115: <span class="ruby-keyword kw">end</span>
|
479
|
+
</pre>
|
480
|
+
</div>
|
481
|
+
</div>
|
482
|
+
</div>
|
483
|
+
|
484
|
+
<div id="method-M000019" class="method-detail">
|
485
|
+
<a name="M000019"></a>
|
486
|
+
|
487
|
+
<div class="method-heading">
|
488
|
+
<a href="#M000019" class="method-signature">
|
489
|
+
<span class="method-name">photos_request</span><span class="method-args">(method, params={})</span>
|
490
|
+
</a>
|
491
|
+
</div>
|
492
|
+
|
493
|
+
<div class="method-description">
|
494
|
+
<p>
|
495
|
+
acts like <a href="Flickr.html#M000018">request</a> but returns a <a
|
496
|
+
href="Flickr/PhotoCollection.html">PhotoCollection</a> (a list of <a
|
497
|
+
href="Flickr/Photo.html">Photo</a> objects)
|
498
|
+
</p>
|
499
|
+
<p><a class="source-toggle" href="#"
|
500
|
+
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
501
|
+
<div class="method-source-code" id="M000019-source">
|
502
|
+
<pre>
|
503
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 191</span>
|
504
|
+
191: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">photos_request</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">params</span>={})
|
505
|
+
192: <span class="ruby-identifier">photos</span> = <span class="ruby-identifier">request</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">params</span>)
|
506
|
+
193: <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>)
|
507
|
+
194: <span class="ruby-keyword kw">end</span>
|
508
|
+
</pre>
|
509
|
+
</div>
|
510
|
+
</div>
|
511
|
+
</div>
|
512
|
+
|
513
|
+
<div id="method-M000007" class="method-detail">
|
514
|
+
<a name="M000007"></a>
|
515
|
+
|
516
|
+
<div class="method-heading">
|
517
|
+
<a href="#M000007" class="method-signature">
|
518
|
+
<span class="method-name">photos_search</span><span class="method-args">(params={})</span>
|
519
|
+
</a>
|
520
|
+
</div>
|
521
|
+
|
522
|
+
<div class="method-description">
|
523
|
+
<p><a class="source-toggle" href="#"
|
524
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
525
|
+
<div class="method-source-code" id="M000007-source">
|
526
|
+
<pre>
|
527
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 123</span>
|
528
|
+
123: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">photos_search</span>(<span class="ruby-identifier">params</span>={})
|
529
|
+
124: <span class="ruby-identifier">photos_request</span>(<span class="ruby-value str">'photos.search'</span>, <span class="ruby-identifier">params</span>)
|
530
|
+
125: <span class="ruby-keyword kw">end</span>
|
531
|
+
</pre>
|
532
|
+
</div>
|
533
|
+
</div>
|
534
|
+
</div>
|
535
|
+
|
536
|
+
<div id="method-M000012" class="method-detail">
|
537
|
+
<a name="M000012"></a>
|
538
|
+
|
539
|
+
<div class="method-heading">
|
540
|
+
<a href="#M000012" class="method-signature">
|
541
|
+
<span class="method-name">photoset</span><span class="method-args">(photoset_id)</span>
|
542
|
+
</a>
|
543
|
+
</div>
|
544
|
+
|
545
|
+
<div class="method-description">
|
546
|
+
<p><a class="source-toggle" href="#"
|
547
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
548
|
+
<div class="method-source-code" id="M000012-source">
|
549
|
+
<pre>
|
550
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 150</span>
|
551
|
+
150: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">photoset</span>(<span class="ruby-identifier">photoset_id</span>)
|
552
|
+
151: <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>)
|
553
|
+
152: <span class="ruby-keyword kw">end</span>
|
554
|
+
</pre>
|
555
|
+
</div>
|
556
|
+
</div>
|
557
|
+
</div>
|
558
|
+
|
559
|
+
<div id="method-M000006" class="method-detail">
|
560
|
+
<a name="M000006"></a>
|
561
|
+
|
562
|
+
<div class="method-heading">
|
563
|
+
<a href="#M000006" class="method-signature">
|
564
|
+
<span class="method-name">recent</span><span class="method-args">()</span>
|
565
|
+
</a>
|
566
|
+
</div>
|
567
|
+
|
568
|
+
<div class="method-description">
|
569
|
+
<p>
|
570
|
+
flickr.photos.getRecent 100 newest <a href="Flickr.html#M000005">photos</a>
|
571
|
+
from everyone
|
572
|
+
</p>
|
573
|
+
<p><a class="source-toggle" href="#"
|
574
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
575
|
+
<div class="method-source-code" id="M000006-source">
|
576
|
+
<pre>
|
577
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 119</span>
|
578
|
+
119: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recent</span>
|
579
|
+
120: <span class="ruby-identifier">photos_request</span>(<span class="ruby-value str">'photos.getRecent'</span>)
|
580
|
+
121: <span class="ruby-keyword kw">end</span>
|
581
|
+
</pre>
|
582
|
+
</div>
|
583
|
+
</div>
|
584
|
+
</div>
|
585
|
+
|
586
|
+
<div id="method-M000013" class="method-detail">
|
587
|
+
<a name="M000013"></a>
|
588
|
+
|
589
|
+
<div class="method-heading">
|
590
|
+
<a href="#M000013" class="method-signature">
|
591
|
+
<span class="method-name">related_tags</span><span class="method-args">(tag)</span>
|
592
|
+
</a>
|
593
|
+
</div>
|
594
|
+
|
595
|
+
<div class="method-description">
|
596
|
+
<p>
|
597
|
+
Implements flickr.tags.getRelated
|
598
|
+
</p>
|
599
|
+
<p><a class="source-toggle" href="#"
|
600
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
601
|
+
<div class="method-source-code" id="M000013-source">
|
602
|
+
<pre>
|
603
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 155</span>
|
604
|
+
155: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">related_tags</span>(<span class="ruby-identifier">tag</span>)
|
605
|
+
156: <span class="ruby-identifier">tags_getRelated</span>(<span class="ruby-value str">'tag'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">tag</span>)[<span class="ruby-value str">'tags'</span>][<span class="ruby-value str">'tag'</span>]
|
606
|
+
157: <span class="ruby-keyword kw">end</span>
|
607
|
+
</pre>
|
608
|
+
</div>
|
609
|
+
</div>
|
610
|
+
</div>
|
611
|
+
|
612
|
+
<div id="method-M000018" class="method-detail">
|
613
|
+
<a name="M000018"></a>
|
614
|
+
|
615
|
+
<div class="method-heading">
|
616
|
+
<a href="#M000018" class="method-signature">
|
617
|
+
<span class="method-name">request</span><span class="method-args">(method, params={})</span>
|
618
|
+
</a>
|
619
|
+
</div>
|
620
|
+
|
621
|
+
<div class="method-description">
|
622
|
+
<p>
|
623
|
+
Takes a <a href="Flickr.html">Flickr</a> API method name and set of
|
624
|
+
parameters; returns an XmlSimple object with the response
|
625
|
+
</p>
|
626
|
+
<p><a class="source-toggle" href="#"
|
627
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
628
|
+
<div class="method-source-code" id="M000018-source">
|
629
|
+
<pre>
|
630
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 183</span>
|
631
|
+
183: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">params</span>={})
|
632
|
+
184: <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>)
|
633
|
+
185: <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-value str">'ForceArray'</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">false</span> })
|
634
|
+
186: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">response</span>[<span class="ruby-value str">'err'</span>][<span class="ruby-value str">'msg'</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span>[<span class="ruby-value str">'stat'</span>] <span class="ruby-operator">!=</span> <span class="ruby-value str">'ok'</span>
|
635
|
+
187: <span class="ruby-identifier">response</span>
|
636
|
+
188: <span class="ruby-keyword kw">end</span>
|
637
|
+
</pre>
|
638
|
+
</div>
|
639
|
+
</div>
|
640
|
+
</div>
|
641
|
+
|
642
|
+
<div id="method-M000020" class="method-detail">
|
643
|
+
<a name="M000020"></a>
|
644
|
+
|
645
|
+
<div class="method-heading">
|
646
|
+
<a href="#M000020" class="method-signature">
|
647
|
+
<span class="method-name">request_url</span><span class="method-args">(method, params={})</span>
|
648
|
+
</a>
|
649
|
+
</div>
|
650
|
+
|
651
|
+
<div class="method-description">
|
652
|
+
<p>
|
653
|
+
Builds url for <a href="Flickr.html">Flickr</a> API REST <a
|
654
|
+
href="Flickr.html#M000018">request</a> from given the flickr method name
|
655
|
+
(exclusing the ‘flickr.’ that begins each method call) and
|
656
|
+
params (where applicable) which should be supplied as a Hash (e.g
|
657
|
+
‘user_id’ => "foo123")
|
658
|
+
</p>
|
659
|
+
<p><a class="source-toggle" href="#"
|
660
|
+
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
661
|
+
<div class="method-source-code" id="M000020-source">
|
662
|
+
<pre>
|
663
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 199</span>
|
664
|
+
199: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request_url</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">params</span>={})
|
665
|
+
200: <span class="ruby-identifier">method</span> = <span class="ruby-value str">'flickr.'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">method</span>
|
666
|
+
201: <span class="ruby-identifier">url</span> = <span class="ruby-node">"#{@host}#{@api}/?api_key=#{@api_key}&method=#{method}"</span>
|
667
|
+
202: <span class="ruby-identifier">params</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-value str">'api_key'</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@api_key</span>, <span class="ruby-value str">'method'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">method</span>, <span class="ruby-value str">'auth_token'</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@auth_token</span>)
|
668
|
+
203: <span class="ruby-identifier">signature</span> = <span class="ruby-identifier">signature_from</span>(<span class="ruby-identifier">params</span>)
|
669
|
+
204:
|
670
|
+
205: <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-value str">'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 kw">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-value str">"&"</span>)
|
671
|
+
206: <span class="ruby-keyword kw">end</span>
|
672
|
+
</pre>
|
673
|
+
</div>
|
674
|
+
</div>
|
675
|
+
</div>
|
676
|
+
|
677
|
+
<div id="method-M000008" class="method-detail">
|
678
|
+
<a name="M000008"></a>
|
679
|
+
|
680
|
+
<div class="method-heading">
|
681
|
+
<span class="method-name">search</span><span class="method-args">(params={})</span>
|
682
|
+
</div>
|
683
|
+
|
684
|
+
<div class="method-description">
|
685
|
+
<p>
|
686
|
+
Alias for <a href="Flickr.html#M000007">photos_search</a>
|
687
|
+
</p>
|
688
|
+
</div>
|
689
|
+
</div>
|
690
|
+
|
691
|
+
<div id="method-M000002" class="method-detail">
|
692
|
+
<a name="M000002"></a>
|
693
|
+
|
694
|
+
<div class="method-heading">
|
695
|
+
<a href="#M000002" class="method-signature">
|
696
|
+
<span class="method-name">set_up_configuration</span><span class="method-args">(api_key_or_params = {})</span>
|
697
|
+
</a>
|
698
|
+
</div>
|
699
|
+
|
700
|
+
<div class="method-description">
|
701
|
+
<p><a class="source-toggle" href="#"
|
702
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
703
|
+
<div class="method-source-code" id="M000002-source">
|
704
|
+
<pre>
|
705
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 87</span>
|
706
|
+
87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_up_configuration</span> <span class="ruby-identifier">api_key_or_params</span> = {}
|
707
|
+
88: <span class="ruby-ivar">@api_key</span> = <span class="ruby-identifier">api_key_or_params</span>[<span class="ruby-identifier">:api_key</span>]
|
708
|
+
89: <span class="ruby-ivar">@shared_secret</span> = <span class="ruby-identifier">api_key_or_params</span>[<span class="ruby-identifier">:shared_secret</span>]
|
709
|
+
90: <span class="ruby-ivar">@auth_token</span> = <span class="ruby-identifier">api_key_or_params</span>[<span class="ruby-identifier">:auth_token</span>]
|
710
|
+
91: <span class="ruby-keyword kw">end</span>
|
711
|
+
</pre>
|
712
|
+
</div>
|
713
|
+
</div>
|
714
|
+
</div>
|
715
|
+
|
716
|
+
<div id="method-M000021" class="method-detail">
|
717
|
+
<a name="M000021"></a>
|
718
|
+
|
719
|
+
<div class="method-heading">
|
720
|
+
<a href="#M000021" class="method-signature">
|
721
|
+
<span class="method-name">signature_from</span><span class="method-args">(params={})</span>
|
722
|
+
</a>
|
723
|
+
</div>
|
724
|
+
|
725
|
+
<div class="method-description">
|
726
|
+
<p><a class="source-toggle" href="#"
|
727
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
728
|
+
<div class="method-source-code" id="M000021-source">
|
729
|
+
<pre>
|
730
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 208</span>
|
731
|
+
208: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">signature_from</span>(<span class="ruby-identifier">params</span>={})
|
732
|
+
209: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@shared_secret</span> <span class="ruby-comment cmt"># don't both getting signature if no shared_secret</span>
|
733
|
+
210: <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 cmt"># build key value pairs, sort in alpha order then join them, ignoring those with nil value</span>
|
734
|
+
211: <span class="ruby-keyword kw">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>)
|
735
|
+
212: <span class="ruby-keyword kw">end</span>
|
736
|
+
</pre>
|
737
|
+
</div>
|
738
|
+
</div>
|
739
|
+
</div>
|
740
|
+
|
741
|
+
<div id="method-M000009" class="method-detail">
|
742
|
+
<a name="M000009"></a>
|
743
|
+
|
744
|
+
<div class="method-heading">
|
745
|
+
<a href="#M000009" class="method-signature">
|
746
|
+
<span class="method-name">tag</span><span class="method-args">(tag)</span>
|
747
|
+
</a>
|
748
|
+
</div>
|
749
|
+
|
750
|
+
<div class="method-description">
|
751
|
+
<p>
|
752
|
+
Gets public <a href="Flickr.html#M000005">photos</a> with a given <a
|
753
|
+
href="Flickr.html#M000009">tag</a>
|
754
|
+
</p>
|
755
|
+
<p><a class="source-toggle" href="#"
|
756
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
757
|
+
<div class="method-source-code" id="M000009-source">
|
758
|
+
<pre>
|
759
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 129</span>
|
760
|
+
129: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tag</span>(<span class="ruby-identifier">tag</span>)
|
761
|
+
130: <span class="ruby-identifier">photos</span>(<span class="ruby-value str">'tags'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">tag</span>)
|
762
|
+
131: <span class="ruby-keyword kw">end</span>
|
763
|
+
</pre>
|
764
|
+
</div>
|
765
|
+
</div>
|
766
|
+
</div>
|
767
|
+
|
768
|
+
<div id="method-M000010" class="method-detail">
|
769
|
+
<a name="M000010"></a>
|
770
|
+
|
771
|
+
<div class="method-heading">
|
772
|
+
<a href="#M000010" class="method-signature">
|
773
|
+
<span class="method-name">users</span><span class="method-args">(lookup=nil)</span>
|
774
|
+
</a>
|
775
|
+
</div>
|
776
|
+
|
777
|
+
<div class="method-description">
|
778
|
+
<p>
|
779
|
+
Implements flickr.people.findByEmail and flickr.people.findByUsername.
|
780
|
+
</p>
|
781
|
+
<p><a class="source-toggle" href="#"
|
782
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
783
|
+
<div class="method-source-code" id="M000010-source">
|
784
|
+
<pre>
|
785
|
+
<span class="ruby-comment cmt"># File lib/flickr.rb, line 134</span>
|
786
|
+
134: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">users</span>(<span class="ruby-identifier">lookup</span>=<span class="ruby-keyword kw">nil</span>)
|
787
|
+
135: <span class="ruby-identifier">user</span> = <span class="ruby-identifier">people_findByEmail</span>(<span class="ruby-value str">'find_email'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">lookup</span>)[<span class="ruby-value str">'user'</span>] <span class="ruby-keyword kw">rescue</span> <span class="ruby-identifier">people_findByUsername</span>(<span class="ruby-value str">'username'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">lookup</span>)[<span class="ruby-value str">'user'</span>]
|
788
|
+
136: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"id"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">user</span>[<span class="ruby-value str">"nsid"</span>], <span class="ruby-value str">"username"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">user</span>[<span class="ruby-value str">"username"</span>], <span class="ruby-value str">"client"</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>)
|
789
|
+
137: <span class="ruby-keyword kw">end</span>
|
790
|
+
</pre>
|
791
|
+
</div>
|
792
|
+
</div>
|
793
|
+
</div>
|
794
|
+
|
795
|
+
|
796
|
+
</div>
|
797
|
+
|
798
|
+
|
799
|
+
</div>
|
800
|
+
|
801
|
+
|
802
|
+
<div id="validator-badges">
|
803
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
804
|
+
</div>
|
805
|
+
|
806
|
+
</body>
|
807
|
+
</html>
|