Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added status update example

  • Loading branch information...
commit 4975a77a028735fa22310c4c1d4054dce5587166 1 parent d18999a
@tardate authored
View
9 app/controllers/members_controller.rb
@@ -29,6 +29,15 @@ def show
end
end
+ def update_status
+ if self.update_status!(params[:status_message])
+ flash[:notice] = 'status update sent'
+ else
+ flash[:error] = 'status update problem'
+ end
+ redirect_to member_path(@member)
+ end
+
def partialfriends
if (request.xhr?)
@friends = self.friends()
View
8 app/views/members/show.html.erb
@@ -20,6 +20,14 @@
</p>
</div>
+<% form_tag update_status_member_path do -%>
+<p>
+ <b>What are you doing?</b><br />
+ <%= text_area_tag 'status_message' %>
+</p>
+<div><%= submit_tag 'Post' %></div>
+<% end -%>
+
<div id="menu">
<%= link_to_remote "Show friends",
:url => partialfriends_member_path(@member),
View
8 config/routes.rb
@@ -3,7 +3,13 @@
map.resources :members,
:collection => { :callback => :get },
- :member => { :partialfriends => :get, :partialfollowers => :get, :partialmentions => :get , :partialdms => :get }
+ :member => {
+ :update_status => :post,
+ :partialfriends => :get,
+ :partialfollowers => :get,
+ :partialmentions => :get ,
+ :partialdms => :get
+ }
map.signout '/signout', :controller => 'members', :action => 'signout'
View
10 lib/oauth_system.rb
@@ -130,6 +130,16 @@ def login_by_oauth
# controller wrappers for twitter API methods
+ # Twitter REST API Method: statuses/update
+ def update_status!( status , in_reply_to_status_id = nil )
+ begin
+ self.twitagent.update_status!( status , in_reply_to_status_id )
+ rescue => err
+ # The user might have rejected this application. Or there was some other error during the request.
+ RAILS_DEFAULT_LOGGER.error "#{err.message} Failed update status"
+ return
+ end
+ end
# Twitter REST API Method: statuses friends
def friends(user=nil)
View
7 lib/twitter_oauth.rb
@@ -338,10 +338,9 @@ def dump_friends( screen_name = nil )
end
def dump_followers( screen_name = nil )
- puts "followers list for #{ screen_name ? screen_name : 'self' }.."
- puts "friends list for #{ screen_name ? screen_name : 'self' }..found #{followers.size} followers.."
- friends = self.followers( screen_name )
- friends.each do |friend|
+ followers = self.followers( screen_name )
+ puts "followers list for #{ screen_name ? screen_name : 'self' }..found #{followers.size} followers.."
+ followers.each do |friend|
puts "\t#{friend['screen_name']}"
end
puts "end followers list for #{ screen_name ? screen_name : 'self' }.."
Please sign in to comment.
Something went wrong with that request. Please try again.