weibo_focus 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # WeiboFocus
2
2
 
3
- TODO: Write a gem description
3
+ interfaces for sina weibo on oauth2
4
4
 
5
5
  ## Installation
6
6
 
@@ -19,41 +19,38 @@ Or install it yourself as:
19
19
  ## Usage
20
20
 
21
21
  ### config/weibo.yml 在新浪应用设置授权回调地址与redirect_uri相同
22
- ````
23
- development:
24
- api_key: your-api-key
25
- api_secret: your-api-secret
26
- redirect_uri: "http://192.168.184.16:3000/home/callback"
27
- ````
22
+
23
+ development:
24
+ api_key: your-api-key
25
+ api_secret: your-api-secret
26
+ redirect_uri: "http://192.168.184.16:3000/home/callback"
28
27
 
29
28
  ### controller
30
- ````
31
- def callback
32
- client = Weibo::Client.new
33
- access_token = client.auth_code.get_token(params[:code].to_s)
34
- session[:uid] = access_token.params["uid"]
35
- session[:access_token] = access_token.token
36
- session[:expires_at] = access_token.expires_at
37
- if user_signed_in?
38
- #把相关信息存入数据库
39
- save_user_key(current_user.id,session[:access_token], session[:expires_at], session[:uid])
40
- end
41
- redirect_to "/home/index"
42
- end
43
-
44
- def connect
45
- client = Weibo::Client.new
46
- redirect_to client.authorize_url
47
- end
48
- ````
29
+
30
+ def callback
31
+ client = Weibo::Client.new
32
+ access_token = client.auth_code.get_token(params[:code].to_s)
33
+ session[:uid] = access_token.params["uid"]
34
+ session[:access_token] = access_token.token
35
+ session[:expires_at] = access_token.expires_at
36
+ if user_signed_in?
37
+ #把相关信息存入数据库
38
+ save_user_key(current_user.id,session[:access_token], session[:expires_at], session[:uid])
39
+ end
40
+ redirect_to "/home/index"
41
+ end
42
+
43
+ def connect
44
+ client = Weibo::Client.new
45
+ redirect_to client.authorize_url
46
+ end
47
+
49
48
  ### 方法调用
50
- ````
51
- client = Weibo::Client.new
52
- client.接口名.方法名(参数详看(新浪api)[http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2])
53
- 例如:获取当前登录用户及其所关注用户的最新微博
54
- @client.statuses.friends_timeline
55
- ````
56
49
 
50
+ client = Weibo::Client.new
51
+ client.接口名.方法名(参数详看新浪api)[http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2]
52
+ 例如:获取当前登录用户及其所关注用户的最新微博
53
+ @client.statuses.friends_timeline
57
54
 
58
55
  ## Contributing
59
56
 
@@ -64,6 +61,13 @@ Or install it yourself as:
64
61
  5. Create new Pull Request
65
62
 
66
63
  ## Error
64
+
67
65
  ### OAuth2::Error (Sorry, that page doesn’t exist!)---without .json
68
- fail:get("tags/suggestions", :params => opt)
69
- ok :get("tags/suggestions.json", :params => opt)
66
+
67
+ error:
68
+
69
+ get("tags/suggestions", :params => opt)
70
+
71
+ ok:
72
+
73
+ get("tags/suggestions.json", :params => opt)
data/README.md~ ADDED
@@ -0,0 +1,73 @@
1
+ # WeiboFocus
2
+
3
+ interfaces for sina weibo on oauth2
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'weibo_focus'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install weibo_focus
18
+
19
+ ## Usage
20
+
21
+ ### config/weibo.yml 在新浪应用设置授权回调地址与redirect_uri相同
22
+
23
+ development:
24
+ api_key: your-api-key
25
+ api_secret: your-api-secret
26
+ redirect_uri: "http://192.168.184.16:3000/home/callback"
27
+
28
+ ### controller
29
+
30
+ def callback
31
+ client = Weibo::Client.new
32
+ access_token = client.auth_code.get_token(params[:code].to_s)
33
+ session[:uid] = access_token.params["uid"]
34
+ session[:access_token] = access_token.token
35
+ session[:expires_at] = access_token.expires_at
36
+ if user_signed_in?
37
+ #把相关信息存入数据库
38
+ save_user_key(current_user.id,session[:access_token], session[:expires_at], session[:uid])
39
+ end
40
+ redirect_to "/home/index"
41
+ end
42
+
43
+ def connect
44
+ client = Weibo::Client.new
45
+ redirect_to client.authorize_url
46
+ end
47
+
48
+ ### 方法调用
49
+
50
+ client = Weibo::Client.new
51
+ client.接口名.方法名(参数详看新浪api)[http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2]
52
+ 例如:获取当前登录用户及其所关注用户的最新微博
53
+ @client.statuses.friends_timeline
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
62
+
63
+ ## Error
64
+
65
+ ### OAuth2::Error (Sorry, that page doesn’t exist!)---without .json
66
+
67
+ error:
68
+
69
+ get("tags/suggestions", :params => opt)
70
+
71
+ ok:
72
+
73
+ get("tags/suggestions.json", :params => opt)
@@ -8,19 +8,19 @@ module Weibo
8
8
  end
9
9
 
10
10
  def get_city(province, opt={})
11
- hashie get("common/send.json", :params => {:province => province}.merge(opt))
11
+ hashie get("common/get_city.json", :params => {:province => province}.merge(opt))
12
12
  end
13
13
 
14
14
  def get_province(country, opt={})
15
- hashie get("common/send.json", :params => {:country => country}.merge(opt))
15
+ hashie get("common/get_province.json", :params => {:country => country}.merge(opt))
16
16
  end
17
17
 
18
18
  def get_country(opt={})
19
- hashie get("common/send.json", :params => {:uids => uids, :tpl_id => tpl_id}.merge(opt))
19
+ hashie get("common/get_country.json", :params => opt)
20
20
  end
21
21
 
22
22
  def get_timezone(opt={})
23
- hashie get("common/send.json", :params => {:uids => uids, :tpl_id => tpl_id}.merge(opt))
23
+ hashie get("common/get_timezone.json", :params => opt)
24
24
  end
25
25
  end
26
26
  end
@@ -0,0 +1,28 @@
1
+ module Weibo
2
+ module Api
3
+ module V2
4
+ class Common < Base
5
+ #read interfaces
6
+ def code_to_location(codes, opt={})
7
+ hashie get("common/code_to_location.json", :params => {:codes => codes}.merge(opt))
8
+ end
9
+
10
+ def get_city(province, opt={})
11
+ hashie get("common/get_city.json", :params => {:province => province}.merge(opt))
12
+ end
13
+
14
+ def get_province(country, opt={})
15
+ hashie get("common/get_province.json", :params => {:country => country}.merge(opt))
16
+ end
17
+
18
+ def get_country(opt={})
19
+ hashie get("common/get_country.json", :params => opt)
20
+ end
21
+
22
+ def get_timezone(opt={})
23
+ hashie get("common/get_timezone.json", :params => opt)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ module Weibo
2
+ module Api
3
+ module V2
4
+ class Notification < Base
5
+ #read interfaces
6
+ def send(uids, tpl_id, opt={})
7
+ hashie get("notification/send", :params => {:uids => uids, :tpl_id => tpl_id}.merge(opt))
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Weibo
2
- VERSION = "1.1.4"
2
+ VERSION = "1.1.5"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Weibo
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weibo_focus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -102,6 +102,7 @@ files:
102
102
  - Gemfile
103
103
  - LICENSE
104
104
  - README.md
105
+ - README.md~
105
106
  - Rakefile
106
107
  - example/.sass-cache/0d4365dd4f25a1b2574fe0fe2e903692b6df08f1/screen.sassc
107
108
  - example/.sass-cache/80b2331c862c6e430e0af18caf62d12d982610f0/screen.sassc
@@ -125,11 +126,13 @@ files:
125
126
  - lib/weibo_focus/api/v2/comments.rb
126
127
  - lib/weibo_focus/api/v2/comments.rb~
127
128
  - lib/weibo_focus/api/v2/common.rb
129
+ - lib/weibo_focus/api/v2/common.rb~
128
130
  - lib/weibo_focus/api/v2/favorites.rb
129
131
  - lib/weibo_focus/api/v2/friendships.rb
130
132
  - lib/weibo_focus/api/v2/friendships.rb~
131
133
  - lib/weibo_focus/api/v2/location.rb
132
134
  - lib/weibo_focus/api/v2/notification.rb
135
+ - lib/weibo_focus/api/v2/notification.rb~
133
136
  - lib/weibo_focus/api/v2/place.rb
134
137
  - lib/weibo_focus/api/v2/register.rb
135
138
  - lib/weibo_focus/api/v2/remind.rb