Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
OAuth gem for rails,支持新浪,腾讯,网易,搜狐微博和豆瓣。
Ruby
Tag: v0.0.1

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
.gitignore
Gemfile
README
Rakefile
oauth_china.gemspec

README

一.简介:
OAuth gem for rails,支持豆瓣,新浪微薄,qq微薄

二.安装:
$ gem install oauth_china

三.使用:

1. 在Gemfile里添加:

gem 'oauth_china'

2. 添加配置文件

config/oauth/douban.yml
config/oauth/sina.yml
config/oauth/qq.yml

 例子:

development:
  key:    "you api key"
  secret: "your secret"
  url:    "http://yoursite.com"
  callback: "http://localhost:3000/your_callback_url"
production:
  key:    "you api key"
  secret: "your secret"
  url:    "http://yoursite.com"
  callback: "http://localhost:3000/your_callback_url"

3.Example
    if params[:oauth_token]
      sina = OauthChina::Sina.load(Rails.cache.read(params[:oauth_token]))
      sina.authorize(:oauth_verifier => params[:oauth_verifier])
      #resp0 = sina.get("http://api.douban.com/people/%40me")
      #resp1 = sina.get("http://open.t.qq.com/api/user/info?format=json")
      resp = sina.get("/account/verify_credentials.xml")
      render :text => resp.body
    else
      sina = OauthChina::Sina.new
      url = sina.authorize_url
      Rails.cache.write(sina.oauth_token, sina.dump)
      redirect_to url
    end
Something went wrong with that request. Please try again.