Module: SocialOauthApi::Base
- Included in:
- Qqdenglu::User, Sinaweibo::User
- Defined in:
- lib/social_oauth_api/base.rb
Constant Summary collapse
- HTTP_TIMEOUT =
15
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#provider_type ⇒ Object
readonly
Returns the value of attribute provider_type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/social_oauth_api/base.rb', line 5 def access_token @access_token end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
5 6 7 |
# File 'lib/social_oauth_api/base.rb', line 5 def client_id @client_id end |
#provider_type ⇒ Object (readonly)
Returns the value of attribute provider_type.
5 6 7 |
# File 'lib/social_oauth_api/base.rb', line 5 def provider_type @provider_type end |
Class Method Details
.klass(str) ⇒ Object
28 29 30 31 32 |
# File 'lib/social_oauth_api/base.rb', line 28 def klass(str) str.split('::').inject(Object) do |mod, class_name| mod.const_get(class_name) end end |
Instance Method Details
#get(url, query) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/social_oauth_api/base.rb', line 15 def get url, query timeout(HTTP_TIMEOUT) do uri = URI(url) uri.query = URI.encode_www_form(query) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == 'https' request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) response.body end end |
#initialize(options) ⇒ Object
9 10 11 12 13 |
# File 'lib/social_oauth_api/base.rb', line 9 def initialize @client_id = [:client_id] @provider_type = [:provider_type] @access_token = [:access_token] end |