百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
O

oauth_china

> 编程语言
开源

Rails 的 OAuth gem,支持新浪、腾讯、网易、搜狐微博和豆瓣。

184 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Rails 的 OAuth gem,支持新浪、腾讯、网易、搜狐微博和豆瓣。

unmaintained

简介

  • 通过OAuth方式同步用户消息到微博平台(支持豆瓣,新浪微薄,腾讯微博,搜狐微博,网易微博)
  • 和omini-auth的区别:omini-auth是专门提供oauth授权和获取用户信息的gem(比如用新浪微博帐号登陆这种需求)
  • oauth_china是一个方便的同步信息到其他微博平台的gem(用来做像follow5.com或http://fanfou.com/settings/sync这样需求)

安装

gem install oauth_china

使用

  • 在Gemfile里添加:
gem 'oauth'
gem 'oauth_china'
  • 添加配置文件
config/oauth/douban.yml
config/oauth/sina.yml
config/oauth/qq.yml
config/oauth/sohu.yml
config/oauth/netease.yml
  • 配置文件格式:
yaml
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"
  • 演示
ruby
#config/routes.rb
match "syncs/:type/new" => "syncs#new", :as => :sync_new
match "syncs/:type/callback" => "syncs#callback", :as => :sync_callback

# encoding: UTF-8
class SyncsController  params[:oauth_verifier])

    results = client.dump

    if results[:access_token] && results[:access_token_secret]
      #在这里把access token and access token secret存到db
      #下次使用的时候:
      #client = OauthChina::Sina.load(:access_token => "xx", :access_token_secret => "xxx")
      #client.add_status("同步到新浪微薄..")
      flash[:notice] = "授权成功!"
    else
      flash[:notice] = "授权失败!"
    end
    redirect_to root_path
  end

  private
  def build_oauth_token_key(name, oauth_token)
    [name, oauth_token].join("_")
  end
end
  • 注意

系统时间要正确设置。否则会出现timstamps refused错误

API文档

  • 腾讯微博API文档:http://open.t.qq.com/resource.php?i=1,1
  • 新浪微博API文档:http://open.t.sina.com.cn/wiki/index.php/API%E6%96%87%E6%A1%A3
  • 豆瓣微博API文档:http://www.douban.com/service/apidoc/reference/

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

You should have read the GNU General Public License before start "RTFSC".

If not, see


By db-china.org

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言