Created
March 28, 2012 13:26
-
-
Save simpx/2226159 to your computer and use it in GitHub Desktop.
Weibo Oauth2 use OAuth2 gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'oauth2' | |
require 'json' | |
OAuth2::Response.register_parser(:text, 'text/plain') do |body| | |
parsed_body = JSON.parse(body) | |
parsed_body | |
end | |
client = OAuth2::Client.new(YOU_KEY, YOU_SECRET, :site => "https://api.weibo.com", :authorize_url => "/oauth2/authorize", :token_url => "/oauth2/access_token") | |
puts client.auth_code.authorize_url(:redirect_uri => YOUR_CALLBACK_URL) | |
token = client.auth_code.get_token('authorization_code_value', :redirect_uri => YOUR_CALLBACK_URL) | |
token.options[:header_format] = 'OAuth2 %s' | |
response = token.get('/2/statuses/public_timeline.json') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment