• Stars
    star
    185
  • Rank 208,271 (Top 5 %)
  • Language
    Ruby
  • Created over 13 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

OAuth gem for rails,支持新浪,腾讯,网易,搜狐微博和豆瓣。

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
  • 配置文件格式:
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"
  • 演示
#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 < ApplicationController

  def new
    client = OauthChina::Sina.new
    authorize_url = client.authorize_url
    Rails.cache.write(build_oauth_token_key(client.name, client.oauth_token), client.dump)
    redirect_to authorize_url
  end

  def callback
    client = OauthChina::Sina.load(Rails.cache.read(build_oauth_token_key(params[:type], params[:oauth_token])))
    client.authorize(:oauth_verifier => 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文档

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 http://www.gnu.org/licenses/


By db-china.org

More Repositories

1

second_level_cache

Write Through and Read Through caching library inspired by CacheMoney and cache_fu, support ActiveRecord 4, 5 and 6.
Ruby
396
star
2

petri_flow

Petri Net Workflow Engine for Ruby.
Ruby
166
star
3

direct_web_spider

A direct web spider framworks for Ruby
Ruby
140
star
4

pgmq

📮🐘 💎 pgmq. Message Queue with Postgres.
PLpgSQL
57
star
5

oh-my-github-circles

GitHub User Circle Generator Using GitHub Actions
JavaScript
47
star
6

schemaless-pg

使用Postgres实现一个Leancloud clone
Ruby
44
star
7

hackernews-insight

Hackernews Insight using TiDB Cloud
21
star
8

pg-fuzzywuzzy

postgresql fuzzywuzzy extension
PLpgSQL
12
star
9

shadow

shadow table.
PLpgSQL
12
star
10

txt2img

txt2img
Ruby
12
star
11

remote_session_demo

Remote Session Demo
Ruby
11
star
12

kiba-plus

Kiba enhancement for Ruby ETL.
Ruby
9
star
13

oh-my-github-dashboard

This repository provides a data pipeline that syncs GitHub repositories with a free MySQL-compatible cloud database, TiDB Cloud. It can be used as a standalone data pipeline or as a personal dashboard.
TypeScript
8
star
14

si9n

语录推荐系统
JavaScript
7
star
15

oh-my-github-pipeline

🔄 A flexible open-source data pipeline for seamlessly syncing data from any github user to your database.
Ruby
6
star
16

repo-track-pipeline

🔄 A flexible open-source data pipeline for seamlessly syncing data from any repository to your database.
Ruby
6
star
17

redundant_column

redundant_column
Ruby
6
star
18

hooopo.github.com

octopress
JavaScript
5
star
19

nolist

Simple Maillist with Mailgun and Sinatra
Ruby
4
star
20

rails-tidb

Ruby
4
star
21

pgmq_worker_ruby_demo

pgmq worker
Ruby
3
star
22

chatgpt-xiaoai

小爱音箱集成LLM,SaaS 服务
Ruby
3
star
23

learn_erlang

learn erlang
Erlang
3
star
24

activerecord-tidb-adapter-demo

Ruby
2
star
25

websocket_sinatra_demo

websocket sinatra demo
Ruby
2
star
26

kiba-plus-demo

Kiba Plus demo.
Ruby
2
star
27

dash-reshape

This is a GitHub tool that provides a comprehensive repository dashboard for analyzing and visualizing GitHub events in a powerful and intuitive way
Ruby
2
star
28

dlt

Data Lake Toolkit for Ruby.
1
star
29

drawerd-server

starter
JavaScript
1
star
30

repo-contributor-circles

GitHub repo contributor circles generator.
JavaScript
1
star
31

mi-service

XiaoMi Cloud Service for mi.com
Ruby
1
star
32

ossinsight-x

Automatically post trending repos to Twitter every day.
Ruby
1
star
33

tidb-serverless-ruby-connect-example

TiDB serverless ruby connect example
Ruby
1
star