Parent

Files

Twitter::Base

Constants

CRLF

Attributes

client[R]

Public Class Methods

new(client) click to toggle source
    # File lib/twitter/base.rb, line 9
 9:     def initialize(client)
10:       @client = client
11:     end

Protected Class Methods

build_multipart_bodies(parts) click to toggle source
     # File lib/twitter/base.rb, line 347
347:     def self.build_multipart_bodies(parts)
348:       boundary = Time.now.to_i.to_s(16)
349:       body = ""
350:       parts.each do |key, value|
351:         esc_key = CGI.escape(key.to_s)
352:         body << "--#{boundary}#{CRLF}"
353:         if value.respond_to?(:read)
354:           body << "Content-Disposition: form-data; name=\"#{esc_key}\"; filename=\"#{File.basename(value.path)}\"#{CRLF}"
355:           body << "Content-Type: #{mime_type(value.path)}#{CRLF*2}"
356:           body << value.read
357:         else
358:           body << "Content-Disposition: form-data; name=\"#{esc_key}\"#{CRLF*2}#{value}"
359:         end
360:         body << CRLF
361:       end
362:       body << "--#{boundary}--#{CRLF*2}"
363:       {
364:         :body => body,
365:         :headers => {"Content-Type" => "multipart/form-data; boundary=#{boundary}"}
366:       }
367:     end
mime_type(file) click to toggle source
     # File lib/twitter/base.rb, line 334
334:     def self.mime_type(file)
335:       case
336:         when file =~ /\.jpg/ then 'image/jpg'
337:         when file =~ /\.gif$/ then 'image/gif'
338:         when file =~ /\.png$/ then 'image/png'
339:         else 'application/octet-stream'
340:       end
341:     end

Public Instance Methods

block(id) click to toggle source
     # File lib/twitter/base.rb, line 222
222:     def block(id)
223:       perform_post("/blocks/create/#{id}.json")
224:     end
blocked_ids() click to toggle source
     # File lib/twitter/base.rb, line 308
308:     def blocked_ids
309:       perform_get("/blocks/blocking/ids.json", :mash => false)
310:     end
blocking(options={}) click to toggle source
     # File lib/twitter/base.rb, line 312
312:     def blocking(options={})
313:       perform_get("/blocks/blocking.json", options)
314:     end
direct_message_create(user, text) click to toggle source
     # File lib/twitter/base.rb, line 129
129:     def direct_message_create(user, text)
130:       perform_post("/direct_messages/new.json", :body => {:user => user, :text => text})
131:     end
direct_message_destroy(id) click to toggle source
     # File lib/twitter/base.rb, line 133
133:     def direct_message_destroy(id)
134:       perform_post("/direct_messages/destroy/#{id}.json")
135:     end
direct_messages(query={}) click to toggle source

Options: since, since_id, page

     # File lib/twitter/base.rb, line 120
120:     def direct_messages(query={})
121:       perform_get("/direct_messages.json", :query => query)
122:     end
direct_messages_sent(query={}) click to toggle source

Options: since, since_id, page

     # File lib/twitter/base.rb, line 125
125:     def direct_messages_sent(query={})
126:       perform_get("/direct_messages/sent.json", :query => query)
127:     end
disable_notifications(id) click to toggle source
     # File lib/twitter/base.rb, line 218
218:     def disable_notifications(id)
219:       perform_post("/notifications/leave/#{id}.json")
220:     end
enable_notifications(id) click to toggle source
     # File lib/twitter/base.rb, line 214
214:     def enable_notifications(id)
215:       perform_post("/notifications/follow/#{id}.json")
216:     end
favorite_create(id) click to toggle source
     # File lib/twitter/base.rb, line 206
206:     def favorite_create(id)
207:       perform_post("/favorites/create/#{id}.json")
208:     end
favorite_destroy(id) click to toggle source
     # File lib/twitter/base.rb, line 210
210:     def favorite_destroy(id)
211:       perform_post("/favorites/destroy/#{id}.json")
212:     end
favorites(query={}) click to toggle source

Options: id, page

     # File lib/twitter/base.rb, line 202
202:     def favorites(query={})
203:       perform_get("/favorites.json", :query => query)
204:     end
follower_ids(query={}) click to toggle source

Options: id, user_id, screen_name

     # File lib/twitter/base.rb, line 161
161:     def follower_ids(query={})
162:       perform_get("/followers/ids.json", :query => query)
163:     end
followers(query={}) click to toggle source

Options: id, user_id, screen_name, page

    # File lib/twitter/base.rb, line 90
90:     def followers(query={})
91:       perform_get("/statuses/followers.json", :query => query)
92:     end
friend_ids(query={}) click to toggle source

Options: id, user_id, screen_name

     # File lib/twitter/base.rb, line 156
156:     def friend_ids(query={})
157:       perform_get("/friends/ids.json", :query => query)
158:     end
friends(query={}) click to toggle source

Options: id, user_id, screen_name, page

    # File lib/twitter/base.rb, line 85
85:     def friends(query={})
86:       perform_get("/statuses/friends.json", :query => query)
87:     end
friends_timeline(query={}) click to toggle source

Options: since_id, max_id, count, page, since

    # File lib/twitter/base.rb, line 19
19:     def friends_timeline(query={})
20:       perform_get("/statuses/friends_timeline.json", :query => query)
21:     end
friendship_create(id, follow=false) click to toggle source
     # File lib/twitter/base.rb, line 137
137:     def friendship_create(id, follow=false)
138:       body = {}
139:       body.merge!(:follow => follow) if follow
140:       perform_post("/friendships/create/#{id}.json", :body => body)
141:     end
friendship_destroy(id) click to toggle source
     # File lib/twitter/base.rb, line 143
143:     def friendship_destroy(id)
144:       perform_post("/friendships/destroy/#{id}.json")
145:     end
friendship_exists?(a, b) click to toggle source
     # File lib/twitter/base.rb, line 147
147:     def friendship_exists?(a, b)
148:       perform_get("/friendships/exists.json", :query => {:user_a => a, :user_b => b})
149:     end
friendship_show(query) click to toggle source
     # File lib/twitter/base.rb, line 151
151:     def friendship_show(query)
152:       perform_get("/friendships/show.json", :query => query)
153:     end
help() click to toggle source
     # File lib/twitter/base.rb, line 235
235:     def help
236:       perform_get("/help/test.json")
237:     end
home_timeline(query={}) click to toggle source

Options: since_id, max_id, count, page

    # File lib/twitter/base.rb, line 14
14:     def home_timeline(query={})
15:       perform_get("/statuses/home_timeline.json", :query => query)
16:     end
is_list_member?(list_owner_username, slug, id) click to toggle source
     # File lib/twitter/base.rb, line 292
292:     def is_list_member?(list_owner_username, slug, id)
293:       perform_get("/#{list_owner_username}/#{slug}/members/#{id}.json").error.nil?
294:     end
list(list_owner_username, slug) click to toggle source
     # File lib/twitter/base.rb, line 262
262:     def list(list_owner_username, slug)
263:       perform_get("/#{list_owner_username}/lists/#{slug}.json")
264:     end
list_add_member(list_owner_username, slug, new_id) click to toggle source
     # File lib/twitter/base.rb, line 284
284:     def list_add_member(list_owner_username, slug, new_id)
285:       perform_post("/#{list_owner_username}/#{slug}/members.json", :body => {:id => new_id})
286:     end
list_create(list_owner_username, options) click to toggle source
     # File lib/twitter/base.rb, line 239
239:     def list_create(list_owner_username, options)
240:       perform_post("/#{list_owner_username}/lists.json", :body => {:user => list_owner_username}.merge(options))
241:     end
list_delete(list_owner_username, slug) click to toggle source
     # File lib/twitter/base.rb, line 247
247:     def list_delete(list_owner_username, slug)
248:       perform_delete("/#{list_owner_username}/lists/#{slug}.json")
249:     end
list_members(list_owner_username, slug, query = {}) click to toggle source
     # File lib/twitter/base.rb, line 280
280:     def list_members(list_owner_username, slug, query = {})
281:       perform_get("/#{list_owner_username}/#{slug}/members.json", :query => query)
282:     end
list_remove_member(list_owner_username, slug, id) click to toggle source
     # File lib/twitter/base.rb, line 288
288:     def list_remove_member(list_owner_username, slug, id)
289:       perform_delete("/#{list_owner_username}/#{slug}/members.json", :query => {:id => id})
290:     end
list_subscribe(list_owner_username, slug) click to toggle source
     # File lib/twitter/base.rb, line 300
300:     def list_subscribe(list_owner_username, slug)
301:       perform_post("/#{list_owner_username}/#{slug}/subscribers.json")
302:     end
list_subscribers(list_owner_username, slug) click to toggle source
     # File lib/twitter/base.rb, line 296
296:     def list_subscribers(list_owner_username, slug)
297:       perform_get("/#{list_owner_username}/#{slug}/subscribers.json")
298:     end
list_timeline(list_owner_username, slug, query = {}) click to toggle source

:per_page = max number of statues to get at once :page = which page of tweets you wish to get

     # File lib/twitter/base.rb, line 268
268:     def list_timeline(list_owner_username, slug, query = {})
269:       perform_get("/#{list_owner_username}/lists/#{slug}/statuses.json", :query => query)
270:     end
list_unsubscribe(list_owner_username, slug) click to toggle source
     # File lib/twitter/base.rb, line 304
304:     def list_unsubscribe(list_owner_username, slug)
305:       perform_delete("/#{list_owner_username}/#{slug}/subscribers.json")
306:     end
list_update(list_owner_username, slug, options) click to toggle source
     # File lib/twitter/base.rb, line 243
243:     def list_update(list_owner_username, slug, options)
244:       perform_put("/#{list_owner_username}/lists/#{slug}.json", :body => options)
245:     end
lists(list_owner_username = nil, query = {}) click to toggle source
     # File lib/twitter/base.rb, line 251
251:     def lists(list_owner_username = nil, query = {})
252:       path = case list_owner_username
253:       when nil, Hash
254:         query = list_owner_username
255:         "/lists.json"
256:       else
257:         "/#{list_owner_username}/lists.json"
258:       end
259:       perform_get(path, :query => query)
260:     end
memberships(list_owner_username, query={}) click to toggle source
     # File lib/twitter/base.rb, line 272
272:     def memberships(list_owner_username, query={})
273:       perform_get("/#{list_owner_username}/lists/memberships.json", :query => query)
274:     end
mentions(query={}) click to toggle source

Options: since_id, max_id, count, page

    # File lib/twitter/base.rb, line 51
51:     def mentions(query={})
52:       perform_get("/statuses/mentions.json", :query => query)
53:     end
rate_limit_status() click to toggle source
     # File lib/twitter/base.rb, line 191
191:     def rate_limit_status
192:       perform_get("/account/rate_limit_status.json")
193:     end
replies(query={}) click to toggle source

DEPRECATED: Use # instead

Options: since_id, max_id, since, page

    # File lib/twitter/base.rb, line 45
45:     def replies(query={})
46:       warn("DEPRECATED: #replies is deprecated by Twitter; use #mentions instead")
47:       perform_get("/statuses/replies.json", :query => query)
48:     end
report_spam(options) click to toggle source

When reporting a user for spam, specify one or more of id, screen_name, or user_id

     # File lib/twitter/base.rb, line 231
231:     def report_spam(options)
232:       perform_post("/report_spam.json", :body => options)
233:     end
retweet(id) click to toggle source
    # File lib/twitter/base.rb, line 80
80:     def retweet(id)
81:       perform_post("/statuses/retweet/#{id}.json")
82:     end
retweeted_by_me(query={}) click to toggle source

Options: since_id, max_id, count, page

    # File lib/twitter/base.rb, line 56
56:     def retweeted_by_me(query={})
57:       perform_get("/statuses/retweeted_by_me.json", :query => query)
58:     end
retweeted_to_me(query={}) click to toggle source

Options: since_id, max_id, count, page

    # File lib/twitter/base.rb, line 61
61:     def retweeted_to_me(query={})
62:       perform_get("/statuses/retweeted_to_me.json", :query => query)
63:     end
retweeters_of(id, options={}) click to toggle source

options: count, page, ids_only

    # File lib/twitter/base.rb, line 71
71:     def retweeters_of(id, options={})
72:       ids_only = !!(options.delete(:ids_only))
73:       perform_get("/statuses/#{id}/retweeted_by#{"/ids" if ids_only}.json", :query => options)
74:     end
retweets(id, query={}) click to toggle source

Options: count

    # File lib/twitter/base.rb, line 33
33:     def retweets(id, query={})
34:       perform_get("/statuses/retweets/#{id}.json", :query => query)
35:     end
retweets_of_me(query={}) click to toggle source

Options: since_id, max_id, count, page

    # File lib/twitter/base.rb, line 66
66:     def retweets_of_me(query={})
67:       perform_get("/statuses/retweets_of_me.json", :query => query)
68:     end
saved_search(id) click to toggle source
     # File lib/twitter/base.rb, line 320
320:     def saved_search(id)
321:       perform_get("/saved_searches/show/#{id}.json")
322:     end
saved_search_create(query) click to toggle source
     # File lib/twitter/base.rb, line 324
324:     def saved_search_create(query)
325:       perform_post("/saved_searches/create.json", :body => {:query => query})
326:     end
saved_search_destroy(id) click to toggle source
     # File lib/twitter/base.rb, line 328
328:     def saved_search_destroy(id)
329:       perform_delete("/saved_searches/destroy/#{id}.json")
330:     end
saved_searches() click to toggle source
     # File lib/twitter/base.rb, line 316
316:     def saved_searches
317:       perform_get("/saved_searches.json")
318:     end
status(id) click to toggle source
    # File lib/twitter/base.rb, line 28
28:     def status(id)
29:       perform_get("/statuses/show/#{id}.json")
30:     end
status_destroy(id) click to toggle source
    # File lib/twitter/base.rb, line 76
76:     def status_destroy(id)
77:       perform_post("/statuses/destroy/#{id}.json")
78:     end
subscriptions(list_owner_username, query = {}) click to toggle source
     # File lib/twitter/base.rb, line 276
276:     def subscriptions(list_owner_username, query = {})
277:       perform_get("/#{list_owner_username}/lists/subscriptions.json", :query => query)
278:     end
unblock(id) click to toggle source
     # File lib/twitter/base.rb, line 226
226:     def unblock(id)
227:       perform_post("/blocks/destroy/#{id}.json")
228:     end
update(status, query={}) click to toggle source

Options: in_reply_to_status_id

    # File lib/twitter/base.rb, line 38
38:     def update(status, query={})
39:       perform_post("/statuses/update.json", :body => {:status => status}.merge(query))
40:     end
update_delivery_device(device) click to toggle source

Device must be sms, im or none

     # File lib/twitter/base.rb, line 170
170:     def update_delivery_device(device)
171:       perform_post("/account/update_delivery_device.json", :body => {:device => device})
172:     end
update_profile(body={}) click to toggle source

One or more of the following must be present:

  name, email, url, location, description
     # File lib/twitter/base.rb, line 197
197:     def update_profile(body={})
198:       perform_post("/account/update_profile.json", :body => body)
199:     end
update_profile_background(file, tile = false) click to toggle source

file should respond to # and #

     # File lib/twitter/base.rb, line 187
187:     def update_profile_background(file, tile = false)
188:       perform_post("/account/update_profile_background_image.json", build_multipart_bodies(:image => file).merge(:tile => tile))
189:     end
update_profile_colors(colors={}) click to toggle source

One or more of the following must be present:

  profile_background_color, profile_text_color, profile_link_color,
  profile_sidebar_fill_color, profile_sidebar_border_color
     # File lib/twitter/base.rb, line 177
177:     def update_profile_colors(colors={})
178:       perform_post("/account/update_profile_colors.json", :body => colors)
179:     end
update_profile_image(file) click to toggle source

file should respond to # and #

     # File lib/twitter/base.rb, line 182
182:     def update_profile_image(file)
183:       perform_post("/account/update_profile_image.json", build_multipart_bodies(:image => file))
184:     end
user(id, query={}) click to toggle source
    # File lib/twitter/base.rb, line 94
94:     def user(id, query={})
95:       perform_get("/users/show/#{id}.json", :query => query)
96:     end
user_search(q, query={}) click to toggle source

Options: page, per_page

     # File lib/twitter/base.rb, line 114
114:     def user_search(q, query={})
115:       q = URI.escape(q)
116:       perform_get("/users/search.json", :query => ({:q => q}.merge(query)))
117:     end
user_timeline(query={}) click to toggle source

Options: id, user_id, screen_name, since_id, max_id, page, since, count

    # File lib/twitter/base.rb, line 24
24:     def user_timeline(query={})
25:       perform_get("/statuses/user_timeline.json", :query => query)
26:     end
users(*ids_or_usernames) click to toggle source
     # File lib/twitter/base.rb, line 98
 98:     def users(*ids_or_usernames)
 99:       ids, usernames = [], []
100:       ids_or_usernames.each do |id_or_username|
101:         if id_or_username.is_a?(Integer)
102:           ids << id_or_username
103:         elsif id_or_username.is_a?(String)
104:           usernames << id_or_username
105:         end
106:       end
107:       query = {}
108:       query[:user_id] = ids.join(",") unless ids.empty?
109:       query[:screen_name] = usernames.join(",") unless usernames.empty?
110:       perform_get("/users/lookup.json", :query => query)
111:     end
verify_credentials() click to toggle source
     # File lib/twitter/base.rb, line 165
165:     def verify_credentials
166:       perform_get("/account/verify_credentials.json")
167:     end

Protected Instance Methods

build_multipart_bodies(parts) click to toggle source
     # File lib/twitter/base.rb, line 369
369:     def build_multipart_bodies(parts) self.class.build_multipart_bodies(parts) end
mime_type(f) click to toggle source
     # File lib/twitter/base.rb, line 343
343:     def mime_type(f) self.class.mime_type(f) end

Private Instance Methods

perform_delete(path, options={}) click to toggle source
     # File lib/twitter/base.rb, line 385
385:     def perform_delete(path, options={})
386:       Twitter::Request.delete(self, path, options)
387:     end
perform_get(path, options={}) click to toggle source
     # File lib/twitter/base.rb, line 373
373:     def perform_get(path, options={})
374:       Twitter::Request.get(self, path, options)
375:     end
perform_post(path, options={}) click to toggle source
     # File lib/twitter/base.rb, line 377
377:     def perform_post(path, options={})
378:       Twitter::Request.post(self, path, options)
379:     end
perform_put(path, options={}) click to toggle source
     # File lib/twitter/base.rb, line 381
381:     def perform_put(path, options={})
382:       Twitter::Request.put(self, path, options)
383:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.