Class: Mogo24r

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/mogo24r.rb,
lib/mogo24r/utils.rb,
lib/mogo24r/timeline_parser.rb

Overview

mogo24r is mogo2API-library for ruby. mogo2 is Japanese micro-blog.

see example/*.rb

Defined Under Namespace

Modules: TimelineParser, Utils

Constant Summary collapse

VERSION =

:nodoc:

'0.0.1'
BaseAddress =

mogo2-API’s BaseAddress.

'http://api.mogo2.jp/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#create_request, #create_uri, #http_access, #parse_options

Constructor Details

#initialize(email, api_key) ⇒ Mogo24r

Description

create mogo24r-instance.

Params

email ([email protected]) api_key (your_mogo2_api_key)

Return

Mogo24r-Instance



37
38
39
40
41
# File 'lib/mogo24r.rb', line 37

def initialize(email, api_key)
  @email = email
  @api_key = api_key
  @user_agent = 'mogo24r (http://mogo24r.rubyforge.org)'
end

Instance Attribute Details

#api_keyObject

User’s API-Key.



19
20
21
# File 'lib/mogo24r.rb', line 19

def api_key
  @api_key
end

#emailObject

User’s Address.



17
18
19
# File 'lib/mogo24r.rb', line 17

def email
  @email
end

#user_agentObject

HTTP_HEADER ‘User-Agent’.



15
16
17
# File 'lib/mogo24r.rb', line 15

def user_agent
  @user_agent
end

Instance Method Details

#get_friends_timeline(options = nil) ⇒ Object

Description

get you and your friends timeline.

Params

options =

:count => get statuses(Integer max=20),
:since => get timeline before date(DateTime)

Return
=> 12345, …, …
RelatedMethods

Mogo24r::Utils#create_uri, Mogo24r::Utils#create_request, Mogo24r::Utils#http_access, Mogo24r::Utils#parse_options, Mogo24r::TimelineParser#parse_timeline



98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/mogo24r.rb', line 98

def get_friends_timeline(options = nil)
  extend TimelineParser
  address = BaseAddress + 'statuses/friends_timeline.xml'
  address += parse_options(options) if options
  uri = create_uri(address)
  request = create_request(:get, uri)
  response = http_access(uri, request)
  if response then
    return parse_timeline(response)
  else
    return false
  end
end

#get_public_timeline(options = nil) ⇒ Object

Description

access for public-timeline.

Params

options = => 12345

Return
=> 12345, …, …
RelatedMethods

Mogo24r::Utils#create_uri, Mogo24r::Utils#create_request, Mogo24r::Utils#http_access, Mogo24r::Utils#parse_options, Mogo24r::TimelineParser#parse_timeline



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/mogo24r.rb', line 63

def get_public_timeline(options = nil)
  extend TimelineParser
  address = BaseAddress + 'statuses/public_timeline.xml'
  address += parse_options(options) if options
  uri = create_uri(address)
  request = create_request(:get, uri)
  response = http_access(uri, request)
  if response then
    return parse_timeline(response)
  else
    return false
  end
end

#get_thread_timeline(thread_id, options = nil) ⇒ Object

Description

get thread timeline.

Params

thread_id = target thred’s id(Integer) options = => get timeline before date(DateTime)

Return
=> 12345, …, …
RelatedMethods

Mogo24r::Utils#create_uri, Mogo24r::Utils#create_request, Mogo24r::Utils#http_access, Mogo24r::Utils#parse_options, Mogo24r::TimelineParser#parse_timeline



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/mogo24r.rb', line 131

def get_thread_timeline(thread_id, options = nil)
  extend TimelineParser
  address = BaseAddress +
    'statuses/thread_timeline/' +
    thread_id + '.xml'
  address += parse_options(options) if options
  uri = crate_uri(address)
  request = create_request(:get, uri)
  response = http_access(uri, request)
  if response then
    return parse_timeline(response)
  else
    return false
  end
end

#get_user_timeline(user_id = nil, options = nil) ⇒ Object

Description

get user’s timeline.

Params

user_id = target user’s id(Integer) options =

:count => get statuses(Integer max=20),
:since => get timeline before date(DateTime)

Return
=> 12345, …, …}
RelatedMethods

Mogo24r::Utils#create_uri, Mogo24r::Utils#create_request, Mogo24r::Utils#http_access, Mogo24r::Utils#parse_options, Mogo24r::TimelineParser#parse_timeline



169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/mogo24r.rb', line 169

def get_user_timeline(user_id = nil, options = nil)
  extend TimellineParser
  address = BaseAddress + 'statuses/user_timeline'
  address += user_id.nil? ? '.xml' : "#{user_id}.xml"
  address += parse_options(options) if options
  uri = create_uri(address)
  request = create_request(:get, uri)
  response = http_access(uri, request)
  if response then
    return parse_timeline
  else
    return false
  end
end

#update_status(status) ⇒ Object

Description

update status.

Params

status(String Encoding: UTF-8)

RelatedMethods

Mogo24r::Utils#create_uri, Mogo24r::Utils#create_request, Mogo24r::Utils#http_access



197
198
199
200
201
202
203
204
205
# File 'lib/mogo24r.rb', line 197

def update_status(status)
  uri = create_uri(
    BaseAddress +
    'statuses/update.xml?status=' +
    status
  )
  request = create_request(:post, uri)
  http_access(uri, request)
end