Method: Twitter::Client#status
- Defined in:
- lib/vendor/twitter/lib/twitter/client/status.rb
#status(action, value = nil) ⇒ Object
Provides access to individual statuses via Twitter’s Status APIs
action can be of the following values:
-
:getto retrieve status content. Assumesvaluegiven responds to :to_i message in meaningful way to yield intended status id. -
:postto publish a new status -
:deleteto remove an existing status. Assumesvaluegiven responds to :to_i message in meaningful way to yield intended status id. -
:replyto reply to an existing status. Assumesvaluegiven isHashwhich contains:in_reply_to_status_idand:status
value should be set to:
-
the status identifier for
:getcase -
the status text message for
:postcase -
none necessary for
:deletecase
Examples:
twitter.status(:get, 107786772)
twitter.status(:post, "New Ruby open source project Twitter4R version 0.2.0 released.")
twitter.status(:delete, 107790712)
An ArgumentError will be raised if an invalid action is given. Valid actions are:
-
:get -
:post -
:delete
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vendor/twitter/lib/twitter/client/status.rb', line 32 def status(action, value = nil) return self.timeline_for(action, value || {}) if :replies == action raise ArgumentError, "Invalid status action: #{action}" unless @@STATUS_URIS.keys.member?(action) return nil unless value uri = @@STATUS_URIS[action] response = nil case action when :get response = http_connect {|conn| create_http_get_request(uri, :id => value.to_i) } when :post response = http_connect({:status => value, :source => @@config.source}.to_http_str) {|conn| create_http_post_request(uri) } when :delete response = http_connect {|conn| create_http_delete_request(uri, :id => value.to_i) } when :reply return nil if (!value.is_a?(Hash) || !value[:status] || !value[:in_reply_to_status_id]) response = http_connect(value.merge(:source => @@config.source).to_http_str) {|conn| create_http_post_request(uri) } end bless_model(Twitter::Status.unmarshal(response.body)) end |