Module: Sinatra::TwitterServer
- Defined in:
- lib/twitter_server.rb
Defined Under Namespace
Modules: Helpers
Constant Summary collapse
- HELP_XML_RESPONSE =
'<ok>true</ok>'.freeze
- HELP_RESPONSE =
'ok'.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #twitter_account_verify_credentials ⇒ Object
- #twitter_basic_auth ⇒ Object
- #twitter_help ⇒ Object
- #twitter_statuses_friends_timeline ⇒ Object
- #twitter_statuses_home_timeline ⇒ Object
- #twitter_statuses_user_timeline ⇒ Object
- #twitter_users_show ⇒ Object
Class Method Details
.registered(app) ⇒ Object
56 57 58 |
# File 'lib/twitter_server.rb', line 56 def self.registered(app) app.helpers Sinatra::TwitterServer::Helpers end |
Instance Method Details
#twitter_account_verify_credentials ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/twitter_server.rb', line 124 def twitter_account_verify_credentials get "/account/verify_credentials.:format" do format = params[:format] = user = yield render_xml_user(user) end end |
#twitter_basic_auth ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/twitter_server.rb', line 60 def twitter_basic_auth before do if base64 = env['HTTP_AUTHORIZATION'] user, pass = Base64.decode64(base64.gsub(/Basic /, '')).split(":") @auth = yield user, pass end end end |
#twitter_help ⇒ Object
136 137 138 139 140 |
# File 'lib/twitter_server.rb', line 136 def twitter_help get "/help/test.:format" do params[:format] == 'xml' ? HELP_XML_RESPONSE : HELP_RESPONSE end end |
#twitter_statuses_friends_timeline ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/twitter_server.rb', line 80 def twitter_statuses_friends_timeline get "/statuses/friends_timeline.:format" do = (:since_id, :max_id, :count, :page) format = params[:format] statuses = yield render_xml_statuses(statuses) end end |
#twitter_statuses_home_timeline ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/twitter_server.rb', line 70 def twitter_statuses_home_timeline get "/statuses/home_timeline.:format" do = (:since_id, :max_id, :count, :page) format = params[:format] statuses = yield render_xml_statuses(statuses) end end |
#twitter_statuses_user_timeline ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/twitter_server.rb', line 90 def twitter_statuses_user_timeline get "/statuses/user_timeline.:format" do = (:user_id, :screen_name, :since_id, :max_id, :count, :page) format = params[:format] statuses = yield render_xml_statuses(statuses) end get "/statuses/user_timeline/:id.:format" do = (:id, :user_id, :screen_name, :since_id, :max_id, :count, :page) format = params[:format] statuses = yield render_xml_statuses(statuses) end end |
#twitter_users_show ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/twitter_server.rb', line 107 def twitter_users_show get "/users/show.:format" do = (:user_id, :screen_name) format = params[:format] user = yield render_xml_user(user) end get "/users/show/:id.:format" do = (:id) format = params[:format] user = yield render_xml_user(user) end end |