rhaiker 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.ja.txt ADDED
@@ -0,0 +1,3 @@
1
+ == 0.0.1 2008-09-04
2
+
3
+ * 初版作成
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-09-04
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Saronpasu
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,34 @@
1
+ History.ja.txt
2
+ History.txt
3
+ License.txt
4
+ Manifest.txt
5
+ README.ja.txt
6
+ README.txt
7
+ Rakefile
8
+ config/hoe.rb
9
+ config/requirements.rb
10
+ example/get_followers.rb
11
+ example/get_following_all_words.rb
12
+ example/get_hot_keywords.rb
13
+ example/haiku_update.rb
14
+ lib/rhaiker.rb
15
+ lib/rhaiker/utils.rb
16
+ lib/rhaiker/version.rb
17
+ lib/rhaiker/xml_parser.rb
18
+ script/console
19
+ script/destroy
20
+ script/generate
21
+ script/txt2html
22
+ setup.rb
23
+ spec/rhaiker_spec.rb
24
+ spec/spec.opts
25
+ spec/spec_helper.rb
26
+ tasks/deployment.rake
27
+ tasks/environment.rake
28
+ tasks/rspec.rake
29
+ tasks/website.rake
30
+ website/index.html
31
+ website/index.txt
32
+ website/javascripts/rounded_corners_lite.inc.js
33
+ website/stylesheets/screen.css
34
+ website/template.html.erb
data/README.ja.txt ADDED
@@ -0,0 +1,34 @@
1
+
2
+ Rhaiker について
3
+
4
+ 1. Rhaiker って何?
5
+
6
+ はてなハイクAPIのrubyライブラリです。
7
+
8
+ 2. はてなハイク とは
9
+
10
+  はてなのマイクロブログサービスです。
11
+
12
+ 3. はてなハイクAPI とは
13
+
14
+  はてなハイクをプログラムから扱うために提供されたWebAPIです。
15
+
16
+ 4. はてなハイクAPI についてもっと詳しく!
17
+
18
+  ここ( http://h.hatena.ne.jp/api ) をご覧ください。
19
+
20
+ 5. はてなハイク についてもっと詳しく!
21
+
22
+  ここ( http://d.hatena.ne.jp/keyword/はてなハイク ) をご覧ください。
23
+
24
+ 6. 使い方
25
+
26
+  使い方の例は、 exsampleフォルダの中にいくつかのサンプルプログラムとして
27
+  記述しています。
28
+  また、RDocで詳細な使い方をご覧いただくこともできます。
29
+
30
+ 7. 作者 について
31
+
32
+  サロンパス(id:saronpasu)です。
33
+
34
+
data/README.txt ADDED
@@ -0,0 +1,51 @@
1
+ = rhaiker - Hatena::Haiku::API ruby binding.
2
+
3
+ http://rhaiker.rubyforge.org/
4
+
5
+ == DESCRIPTION:
6
+
7
+ WebAPI-library for Japanese micro-blog 'Hatena::Haiku'.
8
+ This library create only use Standard-Library on ruby-1.8.x.
9
+
10
+ Hatena::Haiku
11
+ http://h.hatena.ne.jp/
12
+
13
+ Hatena::Haiku::API
14
+ http://h.hatena.ne.jp/api
15
+
16
+ == FEATURES/PROBLEMS:
17
+
18
+ * Still does not support 'Upload ImageFile'.
19
+
20
+ == SYNOPSIS:
21
+
22
+ see exsample/*.rb
23
+
24
+ == INSTALL:
25
+
26
+ gem install rhaiker
27
+
28
+ == LICENSE:
29
+
30
+ (The MIT License)
31
+
32
+ Copyright (c) 2008 Saronpasu
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining
35
+ a copy of this software and associated documentation files (the
36
+ 'Software'), to deal in the Software without restriction, including
37
+ without limitation the rights to use, copy, modify, merge, publish,
38
+ distribute, sublicense, and/or sell copies of the Software, and to
39
+ permit persons to whom the Software is furnished to do so, subject to
40
+ the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be
43
+ included in all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
46
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
48
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
49
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
50
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
51
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
5
+
data/config/hoe.rb ADDED
@@ -0,0 +1,74 @@
1
+ require 'rhaiker/version'
2
+
3
+ AUTHOR = 'saronpasu' # can also be an array of Authors
4
+ EMAIL = "jamneco@gmail.com"
5
+ DESCRIPTION = "Hatena::Haiku::API ruby binding"
6
+ GEM_NAME = 'rhaiker' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'rhaiker' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ # ['activesupport', '>= 1.3.1']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "saronpasu"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = Rhaiker::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'rhaiker documentation',
39
+ "--opname", "index.html",
40
+ "--charset", "utf-8",
41
+ "--line-numbers",
42
+ "--main", "README",
43
+ "--inline-source"]
44
+
45
+ class Hoe
46
+ def extra_deps
47
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
48
+ @extra_deps
49
+ end
50
+ end
51
+
52
+ # Generate all the Rake tasks
53
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
54
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
55
+ p.developer(AUTHOR, EMAIL)
56
+ p.description = DESCRIPTION
57
+ p.summary = DESCRIPTION
58
+ p.url = HOMEPATH
59
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
60
+ p.test_globs = ["test/**/test_*.rb"]
61
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
62
+
63
+ # == Optional
64
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
65
+ #p.extra_deps = EXTRA_DEPENDENCIES
66
+
67
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
68
+ end
69
+
70
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
71
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
72
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
73
+ $hoe.rsync_args = '-av --delete --ignore-errors'
74
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,32 @@
1
+ #!ruby -Ku
2
+ require 'rhaiker'
3
+
4
+ # first you create Rhaiker instance.
5
+ @accessor = Rhaiker.new
6
+
7
+ # if you want 'your data' when must settings.
8
+ @accessor.user_id = 'your hatena_id'
9
+ @accessor.api_key = 'fhrIEhelagF' #@h.hatena.ne.jp
10
+
11
+ # optional settings
12
+ @accessor.user_agent = 'your user_agent'
13
+
14
+ # get follwings member-list.
15
+ followings = @accessor.get_followings
16
+
17
+ # but this case can be.
18
+ followings = @accessor.get_followings('your hatena_id')
19
+
20
+ # return data is ...
21
+ #
22
+ # [ {:id => 'hatena_tarou',
23
+ # :name => 'hatena_tarou',
24
+ # :screen_name => 'hatena_tarou',
25
+ # :followers_count => 0,
26
+ # :url => <URI:: ...>,
27
+ # :profile_image_url => <URI:: ...>},
28
+ # {:id => 'hatena_hanako', ...},
29
+ # {...}, ...]
30
+ #
31
+
32
+
@@ -0,0 +1,29 @@
1
+ #!ruby -Ku
2
+ require 'rhaiker'
3
+
4
+ # first you create Rhaiker instance.
5
+ @accessor = Rhaiker.new
6
+
7
+ # optional settings
8
+ @accessor.user_agent = 'your user_agent'
9
+
10
+ # access to Hateha::Haiku::API
11
+ my_following_words = @accessor.keywords('your hatena_id')
12
+
13
+ # filltering only title.
14
+ mywords = my_following_words.collect{|myword|
15
+ myword[:title]
16
+ }
17
+
18
+ # filltering related-words only title.
19
+ related_words = my_following_words.collect{|myword|
20
+ myword[:related_keywords].collect{|related_word|
21
+ related_word[:title]
22
+ }
23
+ }
24
+
25
+ # following-words and related-words.
26
+ all_words = mywords + related_words
27
+ all_words = all_words.uniq
28
+
29
+
@@ -0,0 +1,17 @@
1
+ #!ruby -Ku
2
+ require 'rhaiker'
3
+
4
+ # first you create Rhaiker instance.
5
+ @accessor = Rhaiker.new
6
+
7
+ # optional settings
8
+ @accessor.user_agent = 'your user_agent'
9
+
10
+ # access to Hateha::Haiku::API
11
+ hot_keywords = @accessor.get_hot_keywords
12
+
13
+ # short case.
14
+ # this code is get 'Hot Keywords' only tiltes.
15
+ hot_keyword_titles = Rhaiker.new.get_hot_keywords.collect{|keyword|keyword[:title]}
16
+
17
+
@@ -0,0 +1,21 @@
1
+ #!ruby -Ku
2
+ require 'rhaiker'
3
+
4
+ # first you create Rhaiker instance.
5
+ @accessor = Rhaiker.new
6
+
7
+ # if you want update when must settings.
8
+ @accessor.user_id = 'your hatena_id'
9
+ @accessor.api_key = 'fhrIEhelagF' #@h.hatena.ne.jp
10
+
11
+ # optional settings
12
+ @accessor.user_agent = 'your user_agent'
13
+ @accessor.source = 'your source keyword'
14
+
15
+ # input status message in UTF-8.
16
+ params = {:status => 'Test Update.'}
17
+
18
+ # status update send Hatena::Haiku::API.
19
+ @accessor.status_update(params)
20
+
21
+
data/lib/rhaiker.rb ADDED
@@ -0,0 +1,767 @@
1
+ #!ruby -Ku
2
+ $:.unshift(File.dirname(__FILE__)) unless
3
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
4
+
5
+ require 'rhaiker/utils'
6
+ require 'rhaiker/xml_parser'
7
+
8
+ =begin rdoc
9
+ Rhaiker is Hatena::Haiku::API ruby binding.
10
+ Use only Pure Ruby library.
11
+
12
+ see exsample/*.rb
13
+
14
+ please show Hatena::Haiku::API::Guide[http://h.hatena.ne.jp/api]
15
+
16
+ =end
17
+ class Rhaiker
18
+ # HTTP-HEADER 'User-Agent' String
19
+ attr_accessor :user_agent
20
+ # Hatena::UserID String
21
+ attr_accessor :user_id
22
+ # Hatena::Haiku::API API-Key String
23
+ attr_accessor :api_key
24
+ # Hatena::Haiku::API ClientSource String
25
+ attr_accessor :source
26
+
27
+ # Hatena::Haiku::API BaseURL
28
+ BaseAddress = 'http://h.hatena.ne.jp/api/'
29
+ # Utilities.
30
+ include Utils
31
+ # Customized XML Parser for
32
+ # Hatena::Haiku::API[http://h.hatena.ne.jp/api]
33
+ include XML_Parser
34
+
35
+ def initialize #:nodoc:
36
+ @user_agent = 'rhaiker'
37
+ @source = 'rhaiker'
38
+ end
39
+
40
+ =begin rdoc
41
+ Description::
42
+ get public-timeline from
43
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-public_timeline]
44
+
45
+ Return::
46
+ timeline ([{:id => 12345, ...}, ...]) or false
47
+
48
+ RelatedMethods::
49
+ Utils#create_uri,
50
+ Utils#create_request,
51
+ Utils#http_access,
52
+ XML_Parser#parse_timeline
53
+ =end
54
+ def get_public_timeline
55
+ uri = create_uri(
56
+ BaseAddress +
57
+ 'statuses/public_timeline.xml'
58
+ )
59
+ request = create_request(:get, uri)
60
+ document = http_access(uri, request)
61
+ if document
62
+ return parse_timeline(document)
63
+ else
64
+ return false
65
+ end
66
+ end
67
+
68
+ =begin rdoc
69
+ Description::
70
+ get friends_timeline from
71
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-friends_timeline]
72
+
73
+ Params::
74
+ user_id (target user_id) [,
75
+ options ({:count => 20, [...]})]
76
+
77
+ Return::
78
+ timeline ([{:id => 12345, ...}, ...]) or false
79
+
80
+ RelatedMethods::
81
+ Utils#create_uri,
82
+ Utils#create_request,
83
+ Utils#parse_options,
84
+ Utils#http_access,
85
+ XML_Parser#parse_timeline,
86
+ =end
87
+ def get_friends_timeline(user_id = nil, options = nil)
88
+ uri_base = BaseAddress + 'statuses/friends_timeline'
89
+ uri_base += user_id ? "/#{user_id}.xml" : '.xml'
90
+ uri_base += parse_options(options) if options
91
+ uri = create_uri(uri_base)
92
+ request = create_request(:get, uri, user_id.nil?)
93
+ document = http_access(uri, request)
94
+ if document
95
+ return parse_timeline(document)
96
+ else
97
+ return false
98
+ end
99
+ end
100
+
101
+ =begin rdoc
102
+ Description::
103
+ get user_timeline from
104
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-user_timeline]
105
+
106
+ Params::
107
+ user_id (target user_id) [,
108
+ options ({:count => 20, [...]})]
109
+
110
+ Return::
111
+ timeline ([{:id => 12345, ...}, ...]) or false
112
+
113
+ RelatedMethods::
114
+ Utils#create_uri,
115
+ Utils#create_request,
116
+ Utils#http_access,
117
+ Utils#parse_options,
118
+ XML_Parser#parse_timeline,
119
+ =end
120
+ def get_user_timeline(user_id = nil, options = nil)
121
+ uri_base = BaseAddress + 'statuses/user_timeline'
122
+ uri_base += user_id ? "/#{user_id}.xml" : '.xml'
123
+ uri_base += parse_options(options) if options
124
+ uri = create_uri(uri_base)
125
+ request = create_request(:get, uri, user_id.nil?)
126
+ document = http_access(uri, request)
127
+ if document
128
+ return parse_timeline(document)
129
+ else
130
+ return false
131
+ end
132
+ end
133
+
134
+ =begin rdoc
135
+ Description::
136
+ get keyword_timeline from
137
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-keyword_timeline]
138
+
139
+ Params::
140
+ keywrod (target keyword) [,
141
+ options ({:count => 20, [...]})]
142
+
143
+ Return::
144
+ timeline ([{:id => 12345, ...}, ...]) or false
145
+
146
+ RelatedMethods::
147
+ Utils#create_uri,
148
+ Utils#create_request,
149
+ Utils#parse_options,
150
+ Utils#http_access,
151
+ XML_Parser#parse_timeline
152
+ =end
153
+ def get_keyword_timeline(keyword, options = nil)
154
+ uri_base = BaseAddress +
155
+ 'statuses/keyword_timeline/' +
156
+ keyword + '.xml'
157
+ uri_base += parse_options(options) if options
158
+ uri = create_uri(uri_base)
159
+ request = create_request(:get, uri)
160
+ document = http_access(uri, request)
161
+ if document
162
+ return parse_timeline(document)
163
+ else
164
+ return false
165
+ end
166
+ end
167
+
168
+ =begin rdoc
169
+ Description::
170
+ get timeline(include picture-url) from
171
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-album]
172
+
173
+ Params::
174
+ keyword (target keyword)
175
+
176
+ Return::
177
+ timeline ([{:id => 12345, ...}, ...]) or false
178
+
179
+ RelatedMethods::
180
+ Utils#create_uri,
181
+ Utils#create_request,
182
+ Utils#parse_options,
183
+ Utils#http_access,
184
+ XML_Parser#parse_timeline
185
+ =end
186
+ def get_album(keyword = nil)
187
+ uri_base = BaseAddress + 'statuses/album'
188
+ uri_base += keyword ? "/#{keyword}.xml" : '.xml'
189
+ uri = create_uri(uri_base)
190
+ request = create_request(:get, uri)
191
+ document = http_access(uri, request)
192
+ if document
193
+ return parse_timeline(document)
194
+ else
195
+ return false
196
+ end
197
+ end
198
+
199
+ =begin rdoc
200
+ Description::
201
+ get status from
202
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-show]
203
+
204
+ Params::
205
+ status_id (target status_id)
206
+
207
+ Return::
208
+ status ({:id => 12345, ...}) or false
209
+
210
+ RelatedMethods::
211
+ Utils#create_uri,
212
+ Utils#create_request,
213
+ Utils#http_access,
214
+ XML_Parser#parse_status
215
+ =end
216
+ def get_status(status_id)
217
+ uri = create_uri(
218
+ BaseAddress +
219
+ 'statuses/show/' +
220
+ status_id.to_s + '.xml'
221
+ )
222
+ request = create_request(:get, uri)
223
+ document = http_access(uri, request)
224
+ if document
225
+ return parse_status(document.root)
226
+ else
227
+ return false
228
+ end
229
+ end
230
+
231
+ =begin rdoc
232
+ Description::
233
+ get friends from
234
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-friends]
235
+
236
+ Params::
237
+ user_id (target user_id)
238
+
239
+ Return::
240
+ users ([{:name => 'hoge', ...}, ...]) or false
241
+
242
+ RelatedMethods::
243
+ Utils#create_uri,
244
+ Utils#create_request,
245
+ Utils#http_access,
246
+ XML_Parser#parse_users
247
+ =end
248
+ def get_friends(user_id = nil)
249
+ uri_base = BaseAddress + 'statuses/friends'
250
+ uri_base += user_id ? "/#{user_id}.xml" : '.xml'
251
+ uri = create_uri(uri_base)
252
+ request = create_request(:get, uri, user_id.nil?)
253
+ document = http_access(uri, request)
254
+ if document
255
+ return parse_users(document)
256
+ else
257
+ return false
258
+ end
259
+ end
260
+
261
+ =begin rdoc
262
+ Description::
263
+ get followers from
264
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-followers]
265
+
266
+ Params::
267
+ user_id (target user_id)
268
+
269
+ Return::
270
+ users ([{:name => 'hoge', ...}, ...]) or false
271
+
272
+ RelatedMethods::
273
+ Utils#create_uri,
274
+ Utils#create_request,
275
+ Utils#http_access,
276
+ XML_Parser#parse_users
277
+ =end
278
+ def get_followers(user_id = nil)
279
+ uri_base = BaseAddress + 'statuses/followers'
280
+ uri_base += user_id ? "/#{user_id}.xml" : '.xml'
281
+ uri = create_uri(uri_base)
282
+ request = create_request(:get, uri, user_id.nil?)
283
+ document = http_access(uri, request)
284
+ if document
285
+ return parse_users(document)
286
+ else
287
+ return false
288
+ end
289
+ end
290
+
291
+ =begin rdoc
292
+ Description::
293
+ get friend from
294
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#friendship-show]
295
+
296
+ Params::
297
+ user_id (target user_id)
298
+
299
+ Return::
300
+ user ({:name => 'hoge', ...}) or false
301
+
302
+ RelatedMethods::
303
+ Utils#create_uri,
304
+ Utils#create_request,
305
+ Utils#http_access,
306
+ XML_Parser#parse_user
307
+ =end
308
+ def get_friend(user_id)
309
+ uri = create_uri(
310
+ BaseAddress +
311
+ 'friendships/show/' +
312
+ user_id + '.xml'
313
+ )
314
+ request = create_request(:get, uri)
315
+ document = http_access(uri, request)
316
+ if document
317
+ return parse_user(document.root)
318
+ else
319
+ return false
320
+ end
321
+ end
322
+
323
+ =begin rdoc
324
+ Description::
325
+ get hot-keyword from
326
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#keywords-hot]
327
+
328
+ Return::
329
+ keywords ([{:title => 'hoge', ...}, ...]) or false
330
+
331
+ RelatedMethods::
332
+ Utils#create_uri,
333
+ Utils#create_request,
334
+ Utils#http_access,
335
+ XML_Parser#parse_keywords
336
+ =end
337
+ def get_hot_keywords
338
+ uri = create_uri(BaseAddress + 'keywords/hot.xml')
339
+ request = create_request(:get, uri)
340
+ document = http_access(uri, request)
341
+ if document
342
+ return parse_keywords(document)
343
+ else
344
+ return false
345
+ end
346
+ end
347
+
348
+ =begin rdoc
349
+ Description::
350
+ get keyword-list from
351
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#keywords-list]
352
+
353
+ Params::
354
+ options => {:page => pagenum}
355
+
356
+ Return::
357
+ keywords ([{:title => 'hoge', ...}, ...]) or false
358
+
359
+ RelatedMethods::
360
+ Utils#create_uri,
361
+ Utils#create_request,
362
+ Utils#parse_options,
363
+ Utils#http_access,
364
+ XML_Parser#parse_keywords
365
+ =end
366
+ def get_keyword_list(options = nil)
367
+ uri_base = BaseAddress + 'keywords/list.xml'
368
+ uri_base += parse_options(options) if options
369
+ uri = create_uri(uri_base)
370
+ request = create_request(:get, uri)
371
+ document = http_access(uri, request)
372
+ if document
373
+ return parse_keywords(document)
374
+ else
375
+ return false
376
+ end
377
+ end
378
+
379
+ =begin rdoc
380
+ Description::
381
+ get following keywords from
382
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-keywords]
383
+
384
+ Params::
385
+ user_id (target user_id)
386
+
387
+ Return::
388
+ keywords ([{:title => 'hoge', ...}, ...]) or false
389
+
390
+ RelatedMethods::
391
+ Utils#create_uri
392
+ Utils#create_request
393
+ Utils#http_access
394
+ XML_Parser#parse_keywords
395
+ =end
396
+ def get_keywords(user_id = nil)
397
+ uri_base = BaseAddress + 'statuses/keywrods'
398
+ uri_base += user_id ? "/#{user_id}.xml" : '.xml'
399
+ uri = create_uri(uri_base)
400
+ request = create_request(:get, uri, user_id.nil?)
401
+ document = http_access(uri, request)
402
+ if document
403
+ return parse_timeline(document)
404
+ else
405
+ return false
406
+ end
407
+ end
408
+
409
+ =begin rdoc
410
+ Description::
411
+ get keyword from
412
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#keywords-show]
413
+
414
+ Params::
415
+ keyword (target keyword)
416
+
417
+ Return::
418
+ keyword ({:title => 'hoge', ...}) or false
419
+
420
+ RelatedMethods::
421
+ Utils#create_uri,
422
+ Utils#create_request,
423
+ Utils#http_access,
424
+ XML_Parser#parse_keyword
425
+ =end
426
+ def get_keyword(keyword)
427
+ uri = create_uri(
428
+ BaseAddress +
429
+ 'keywords/show/' +
430
+ keyword + 'xml'
431
+ )
432
+ request = create_request(:get, uri)
433
+ document = http_access(uri, request)
434
+ if document
435
+ return parse_keyword(document.root)
436
+ else
437
+ return false
438
+ end
439
+ end
440
+
441
+ =begin rdoc
442
+ Description::
443
+ update status for
444
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-update]
445
+
446
+ Params::
447
+ options ({:status => 'hoge', ...}]
448
+
449
+ Return::
450
+ status ({:text => 'hoge', ...}) or false
451
+
452
+ RelatedMethods::
453
+ Utils#create_uri,
454
+ Utils#create_request,
455
+ Utils#parse_options,
456
+ Utils#http_access,
457
+ XML_Parser#parse_status
458
+
459
+ Notes::
460
+ Still does not support of 'Upload Image File'
461
+ =end
462
+ def status_update(options)
463
+ uri_base = BaseAddress + 'statuses/update.xml'
464
+ uri_base += parse_options(options)
465
+ uri_base += '&source=' + @source
466
+ uri = create_uri(uri_base)
467
+ request = create_request(:post, uri, true)
468
+ document = http_access(uri, request)
469
+ if document
470
+ return parse_status(document.root)
471
+ else
472
+ return false
473
+ end
474
+ end
475
+
476
+ =begin rdoc
477
+ Description::
478
+ delete status for
479
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#statuses-destroy]
480
+
481
+ Params::
482
+ status_id (target status_id)
483
+
484
+ Return::
485
+ status ({:text => 'hoge', ...}) or false
486
+
487
+ RelationMethods::
488
+ create_uri,
489
+ create_request,
490
+ http_access,
491
+ parse_status
492
+ =end
493
+ def status_destroy(status_id)
494
+ uri = create_uri(
495
+ BaseAddress +
496
+ 'statuses/status/destroy/' +
497
+ status_id.to_s + '.xml'
498
+ )
499
+ request = create_request(:post, uri, true)
500
+ document = http_access(uri, request)
501
+ if document
502
+ return parse_status(document.root)
503
+ else
504
+ return false
505
+ end
506
+ end
507
+
508
+ =begin rdoc
509
+ Description::
510
+ friend following for
511
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#friendship-create]
512
+
513
+ Params::
514
+ user_id (target user_id)
515
+
516
+ Return::
517
+ user ({:id => 'hoge', ...}) or false
518
+
519
+ RelatedMethods::
520
+ Utils#create_uri,
521
+ Utils#create_request,
522
+ Utils#http_access,
523
+ XML_Parser#parse_user
524
+ =end
525
+ def friendship_create(user_id)
526
+ uri = create_uri(
527
+ BaseAddress +
528
+ 'friendships/create/' +
529
+ user_id + '.xml'
530
+ )
531
+ request = create_request(:post, uri, true)
532
+ document = http_access(uri, request)
533
+ if document
534
+ return parse_user(document.root)
535
+ else
536
+ return false
537
+ end
538
+ end
539
+
540
+ =begin rdoc
541
+ Description::
542
+ friend unfollowing for
543
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#friendship-destroy]
544
+
545
+ Params::
546
+ user_id (target user_id)
547
+
548
+ Return::
549
+ user ({:id => 'hoge', ...}) or false
550
+
551
+ RelatedMethods::
552
+ Utils#create_uri,
553
+ Utils#create_request,
554
+ Utils#http_access,
555
+ XML_Parser#parse_user
556
+ =end
557
+ def friendship_destroy(user_id)
558
+ uri = create_uri(
559
+ BaseAddress +
560
+ 'friendships/destroy/' +
561
+ user_id + '.xml'
562
+ )
563
+ request = create_request(:post, uri, true)
564
+ document = http_access(uri, request)
565
+ if document
566
+ return parse_user(document.root)
567
+ else
568
+ return false
569
+ end
570
+ end
571
+
572
+ =begin rdoc
573
+ Description::
574
+ add star for
575
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#favorites-create]
576
+
577
+ Params::
578
+ status_id (target status_id)
579
+
580
+ Return::
581
+ status ({:text => 'hoge', ...}) or false
582
+
583
+ RelatedMethods::
584
+ Utils#create_uri,
585
+ Utils#create_request,
586
+ Utils#http_access,
587
+ XML_Parser#parse_status
588
+ =end
589
+ def favorites_create(status_id)
590
+ uri = create_uri(
591
+ BaseAddress +
592
+ 'favorites/create/' +
593
+ status_id.to_s + '.xml'
594
+ )
595
+ request = create_request(:post, uri, true)
596
+ document = http_access(uri, request)
597
+ if document
598
+ return parse_status(document.root)
599
+ else
600
+ return false
601
+ end
602
+ end
603
+
604
+ =begin rdoc
605
+ Description::
606
+ delete star for
607
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#favorites-destroy]
608
+
609
+ Params::
610
+ status_id (target status_id)
611
+
612
+ Return::
613
+ status {:text => 'hoge', ...}) or false
614
+
615
+ RelatedMethods::
616
+ Utils#create_uri,
617
+ Utils#create_request,
618
+ Utils#http_access,
619
+ XML_Parser#parse_status
620
+ =end
621
+ def favorites_destroy(status_id)
622
+ uri = create_uri(
623
+ BaseAddress +
624
+ 'favorites/destroy/' +
625
+ status_id.to_s + '.xml'
626
+ )
627
+ request = create_request(:post, uri, true)
628
+ document = http_access(uri, request)
629
+ if document
630
+ return parse_status(document.root)
631
+ else
632
+ return false
633
+ end
634
+ end
635
+
636
+ =begin rdoc
637
+ Description::
638
+ following keyword for
639
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#keywords-create]
640
+
641
+ Params::
642
+ keyword (target keyword)
643
+
644
+ Return::
645
+ keyword ({:title => 'hoge', ...} or false
646
+
647
+ RelatedMethods::
648
+ Utils#create_uri,
649
+ Utils#create_request,
650
+ Utils#http_access,
651
+ XML_Parser#parse_keyword
652
+ =end
653
+ def keyword_create(keyword)
654
+ uri = create_uri(
655
+ BaseAddress +
656
+ 'keywords/create/' +
657
+ keyword + '.xml'
658
+ )
659
+ request = create_request(:post, uri, true)
660
+ document = http_access(uri, request)
661
+ if document
662
+ return parse_keyword(document.root)
663
+ else
664
+ return false
665
+ end
666
+ end
667
+
668
+ =begin rdoc
669
+ Description::
670
+ unfollowing keyword for
671
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#keywords-destroy]
672
+
673
+ Params::
674
+ keyword (target keyword)
675
+
676
+ Return::
677
+ keyword ({:title => 'hoge', ...}) or false
678
+
679
+ RelatedMethods::
680
+ Utils#create_uri,
681
+ Utils#create_request,
682
+ Utils#http_access,
683
+ XML_Parser#parse_keyword
684
+ =end
685
+ def keyword_destroy(keyword)
686
+ uri = create_uri(
687
+ BaseAddress +
688
+ 'keywords/destroy/' +
689
+ keyword + '.xml'
690
+ )
691
+ request = create_request(:post, uri, true)
692
+ document = http_access(uri, request)
693
+ if document
694
+ return parse_keyword(document.root)
695
+ else
696
+ return false
697
+ end
698
+ end
699
+
700
+ =begin rdoc
701
+ Description::
702
+ create relation word1 and word2 for
703
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#keywords-relation_create]
704
+
705
+ Params::
706
+ word1 (target word),
707
+ word2 (target word)
708
+
709
+ Return::
710
+ keyword ({:title => 'hoge', ...}) or false
711
+
712
+ RelatedMethods::
713
+ Utils#create_uri,
714
+ Utils#create_request,
715
+ Utils#http_access,
716
+ XML_Parser#parse_keyword
717
+ =end
718
+ def keyword_relation_create(word1, word2)
719
+ uri = create_uri(
720
+ BaseAddress +
721
+ 'keywords/relation/create.xml' +
722
+ '?word1=' + word1 +
723
+ '&word2=' + word2
724
+ )
725
+ request = create_request(:post, uri, true)
726
+ document = http_access(uri, request)
727
+ if document
728
+ return parse_keyword(document.root)
729
+ else
730
+ return false
731
+ end
732
+ end
733
+
734
+ =begin rdoc
735
+ Description::
736
+ delete relation word1 and word2 for
737
+ Hatena::Haiku::API[http://h.hatena.ne.jp/api#keywords-relation_destroy]
738
+
739
+ Params::
740
+ word1 (target word),
741
+ word2 (rarget word)
742
+
743
+ Return::
744
+ keyword ({:title => 'hoge', ...}) or false
745
+
746
+ RelatedMethods::
747
+ Utils#create_uri,
748
+ Utils#create_request,
749
+ Utils#http_access,
750
+ XML_Parser#parse_keyword
751
+ =end
752
+ def keyword_relation_destroy(word1, word2)
753
+ uri = create_uri(
754
+ BaseAddress +
755
+ 'keywords/relation/destroy.xml' +
756
+ '?word1=' + word1 +
757
+ '&word2=' + word2
758
+ )
759
+ request = create_request(:post, uri, true)
760
+ document = http_access(uri, request)
761
+ if document
762
+ return parse_keyword(document.root)
763
+ else
764
+ return false
765
+ end
766
+ end
767
+ end