Class: OmniAuth::Strategies::Weibo
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Weibo
- Defined in:
- lib/omniauth/strategies/weibo.rb
Instance Method Summary collapse
-
#authorize_params ⇒ Object
You can pass
display
,with_offical_account
orstate
params to the auth request, if you need to set them dynamically. - #find_image ⇒ Object
-
#image_url ⇒ Object
url: option: size: avatar_hd original original_size avatar_large large 180x180 profile_image_url middle 50x50 small 30x30 default is middle.
- #raw_info ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
You can pass display
, with_offical_account
or state
params to the auth request, if you need to set them dynamically. You can also set these options in the OmniAuth config :authorize_params option.
/auth/weibo?display=mobile&with_offical_account=1
78 79 80 81 82 83 84 85 86 |
# File 'lib/omniauth/strategies/weibo.rb', line 78 def super.tap do |params| %w[display with_offical_account forcelogin].each do |v| if request.params[v] params[v.to_sym] = request.params[v] end end end end |
#find_image ⇒ Object
47 48 49 |
# File 'lib/omniauth/strategies/weibo.rb', line 47 def find_image raw_info[%w(avatar_hd avatar_large profile_image_url).find { |e| raw_info[e].present? }] end |
#image_url ⇒ Object
url: option: size: avatar_hd original original_size avatar_large large 180x180 profile_image_url middle 50x50
small 30x30
default is middle
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/omniauth/strategies/weibo.rb', line 57 def image_url image_size = [:image_size] || :middle case image_size.to_sym when :original url = raw_info['avatar_hd'] when :large url = raw_info['avatar_large'] when :small url = raw_info['avatar_large'].sub('/180/','/30/') else url = raw_info['profile_image_url'] end end |
#raw_info ⇒ Object
40 41 42 43 44 45 |
# File 'lib/omniauth/strategies/weibo.rb', line 40 def raw_info access_token.[:mode] = :query access_token.[:param_name] = 'access_token' @uid ||= access_token.get('/2/account/get_uid.json').parsed["uid"] @raw_info ||= access_token.get("/2/users/show.json", :params => {:uid => @uid}).parsed end |