Class: DaumOAuth::Client
- Inherits:
-
Object
- Object
- DaumOAuth::Client
- Defined in:
- lib/daum_oauth/blog.rb,
lib/daum_oauth/cafe.rb,
lib/daum_oauth/yozm.rb,
lib/daum_oauth/client.rb
Instance Method Summary collapse
- #authentication_request_token(options = {}) ⇒ Object
- #authorize(token, secret, options = {}) ⇒ Object
- #blog_post_list(blogName, options = {}) ⇒ Object
- #blog_post_modify(blogName, postId, title, content, tag, options = {}) ⇒ Object
- #blog_post_read(blogName, posdId) ⇒ Object
- #blog_post_write(blogName, title, content, tag, options = {}) ⇒ Object
- #cafe_alimis ⇒ Object
- #cafe_articles(cafeCode, boardId, page = 1) ⇒ Object
- #cafe_boards(cafeCode) ⇒ Object
- #cafe_favorites ⇒ Object
- #cafe_recent_articles(cafeCode) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #request_token(options = {}) ⇒ Object
-
#yozm_add(message, options = {}) ⇒ Object
send a message to yozm.
-
#yozm_authorized? ⇒ Boolean
check if authorized to yozm.
-
#yozm_home_timeline(options = {}) ⇒ Object
available options: max_msg_id, since_msg_id, count.
-
#yozm_join(nickname, options = {}) ⇒ Object
join yozm.
-
#yozm_joined? ⇒ Boolean
check if a user joined yozm.
-
#yozm_search(q, options = {}) ⇒ Object
available options: type(message - default, tag), page, count.
-
#yozm_show(options = nil) ⇒ Object
gets user info if authorized with oauth, the authorized user’s info will be returned.
-
#yozm_user_timeline(url_name, options = {}) ⇒ Object
available options: next(=since_msg_id?, count).
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 |
# File 'lib/daum_oauth/client.rb', line 8 def initialize( = {}) @consumer_key = [:consumer_key] @consumer_secret = [:consumer_secret] @token = [:token] @secret = [:secret] #@callback_url = options[:callback_url] end |
Instance Method Details
#authentication_request_token(options = {}) ⇒ Object
30 31 32 |
# File 'lib/daum_oauth/client.rb', line 30 def authentication_request_token( = {}) request_token() end |
#authorize(token, secret, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/daum_oauth/client.rb', line 16 def (token, secret, = {}) request_token = OAuth::RequestToken.new( consumer, token, secret ) @access_token = request_token.get_access_token() @token = @access_token.token @secret = @access_token.secret @access_token end |
#blog_post_list(blogName, options = {}) ⇒ Object
5 6 7 8 |
# File 'lib/daum_oauth/blog.rb', line 5 def blog_post_list(blogName, ={}) puts "/blog/post/list.do?#{.merge(:blogName => blogName, :output => 'json').collect{|k, v| "#{k}=#{v}"}.join('&')}" get("/blog/post/list.do?#{.merge(:blogName => blogName, :output => 'json').collect{|k, v| "#{k}=#{v}"}.join('&')}") end |
#blog_post_modify(blogName, postId, title, content, tag, options = {}) ⇒ Object
14 15 16 |
# File 'lib/daum_oauth/blog.rb', line 14 def blog_post_modify(blogName, postId, title, content, tag, ={}) post("/blog/post/modify.do", .merge(:blogName => blogName, :postId => postId, :title => title, :content => content, :tag => tag, :output => 'json')) end |
#blog_post_read(blogName, posdId) ⇒ Object
18 19 20 |
# File 'lib/daum_oauth/blog.rb', line 18 def blog_post_read(blogName, posdId) post("/blog/post/read.do?blogName=#{blogName}&postId=#{postId}&output=json") end |
#blog_post_write(blogName, title, content, tag, options = {}) ⇒ Object
10 11 12 |
# File 'lib/daum_oauth/blog.rb', line 10 def blog_post_write(blogName, title, content, tag, ={}) post("/blog/post/write.do", .merge(:blogName => blogName, :title => title, :content => content, :tag => tag, :output => 'json')) end |
#cafe_alimis ⇒ Object
9 10 11 |
# File 'lib/daum_oauth/cafe.rb', line 9 def cafe_alimis get("/cafe/alimis.json") end |
#cafe_articles(cafeCode, boardId, page = 1) ⇒ Object
13 14 15 |
# File 'lib/daum_oauth/cafe.rb', line 13 def cafe_articles(cafeCode, boardId, page=1) get("/cafe/articles/#{cafeCode}/#{boardId}.json?page=#{page}") end |
#cafe_boards(cafeCode) ⇒ Object
17 18 19 |
# File 'lib/daum_oauth/cafe.rb', line 17 def cafe_boards(cafeCode) get("/cafe/boards/#{cafeCode}.json") end |
#cafe_favorites ⇒ Object
5 6 7 |
# File 'lib/daum_oauth/cafe.rb', line 5 def cafe_favorites get("/cafe/favorite_cafes.json") end |
#cafe_recent_articles(cafeCode) ⇒ Object
21 22 23 |
# File 'lib/daum_oauth/cafe.rb', line 21 def cafe_recent_articles(cafeCode) get("/cafe/recent_articles/#{cafeCode}.json") end |
#request_token(options = {}) ⇒ Object
26 27 28 |
# File 'lib/daum_oauth/client.rb', line 26 def request_token(={}) consumer.get_request_token() end |
#yozm_add(message, options = {}) ⇒ Object
send a message to yozm
28 29 30 31 |
# File 'lib/daum_oauth/yozm.rb', line 28 def yozm_add(, ={}) #available options: url_shorten, img_url, parent_msg_id #get("/yozm/v1_0/message/add.json?#{options.merge(:message => URI.encode(message)).collect{|k, v| "#{k}=#{v}"}.join('&')}") post("/yozm/v1_0/message/add.json", .merge(:message => )) end |
#yozm_authorized? ⇒ Boolean
check if authorized to yozm
7 8 9 10 |
# File 'lib/daum_oauth/yozm.rb', line 7 def user_info = yozm_show !user_info.nil? and user_info['status'] == 200 end |
#yozm_home_timeline(options = {}) ⇒ Object
available options: max_msg_id, since_msg_id, count
47 48 49 |
# File 'lib/daum_oauth/yozm.rb', line 47 def yozm_home_timeline(={}) #available options: max_msg_id, since_msg_id, count get("/yozm/v1_0/timeline/home.json?#{.collect{|k,v| "#{k}=#{v}"}.join('&')}") end |
#yozm_join(nickname, options = {}) ⇒ Object
join yozm
39 40 41 |
# File 'lib/daum_oauth/yozm.rb', line 39 def yozm_join(nickname, ={}) #available options: sex(N/F/M), birthday(1984-11-14), blood_type(N/A/B/AB/O) post("/yozm/v1_0/user/join.json", .merge(:nickname => nickname)) end |
#yozm_joined? ⇒ Boolean
check if a user joined yozm
34 35 36 |
# File 'lib/daum_oauth/yozm.rb', line 34 def yozm_joined? get("/yozm/v1_0/user/joined.json") end |
#yozm_search(q, options = {}) ⇒ Object
available options: type(message - default, tag), page, count
43 44 45 |
# File 'lib/daum_oauth/yozm.rb', line 43 def yozm_search(q, ={}) #available options: type(message - default, tag), page, count get("/yozm/v1_0/timeline/search.json?#{.merge(:q => q).collect{|k,v| "#{k}=#{v}"}.join('&')}") end |
#yozm_show(options = nil) ⇒ Object
gets user info if authorized with oauth, the authorized user’s info will be returned. Otherwise, you can specify nick_name or url_name.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/daum_oauth/yozm.rb', line 15 def yozm_show( = nil) if .nil? return get("/yozm/v1_0/user/show.json") elsif [:url_name] return get("/yozm/v1_0/user/show.json?url_name=#{[:url_name]}") elsif [:nick_name] return get("/yozm/v1_0/user/show.json?nick_name=#{[:nick_name]}") else return get("/yozm/v1_0/user/show.json") end end |
#yozm_user_timeline(url_name, options = {}) ⇒ Object
available options: next(=since_msg_id?, count)
51 52 53 |
# File 'lib/daum_oauth/yozm.rb', line 51 def yozm_user_timeline(url_name, ={}) #available options: next(=since_msg_id?, count) get("/yozm/v1_0/timeline/user.json?#{.merge(:url_name => url_name).collect{|k,v| "#{k}=#{v}"}.join('&')}") end |