weibo_focus 1.1.3 → 1.1.4

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
@@ -18,7 +18,42 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
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
+
29
+ ### 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
+ ````
49
+ ### 方法调用
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
+
22
57
 
23
58
  ## Contributing
24
59
 
@@ -27,3 +62,8 @@ TODO: Write usage instructions here
27
62
  3. Commit your changes (`git commit -am 'Added some feature'`)
28
63
  4. Push to the branch (`git push origin my-new-feature`)
29
64
  5. Create new Pull Request
65
+
66
+ ## Error
67
+ ### 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)
@@ -4,23 +4,23 @@ module Weibo
4
4
  class Common < Base
5
5
  #read interfaces
6
6
  def code_to_location(codes, opt={})
7
- hashie get("common/code_to_location", :params => {:codes => codes}.merge(opt))
7
+ hashie get("common/code_to_location.json", :params => {:codes => codes}.merge(opt))
8
8
  end
9
9
 
10
10
  def get_city(province, opt={})
11
- hashie get("common/send", :params => {:province => province}.merge(opt))
11
+ hashie get("common/send.json", :params => {:province => province}.merge(opt))
12
12
  end
13
13
 
14
14
  def get_province(country, opt={})
15
- hashie get("common/send", :params => {:country => country}.merge(opt))
15
+ hashie get("common/send.json", :params => {:country => country}.merge(opt))
16
16
  end
17
17
 
18
18
  def get_country(opt={})
19
- hashie get("common/send", :params => {:uids => uids, :tpl_id => tpl_id}.merge(opt))
19
+ hashie get("common/send.json", :params => {:uids => uids, :tpl_id => tpl_id}.merge(opt))
20
20
  end
21
21
 
22
22
  def get_timezone(opt={})
23
- hashie get("common/send", :params => {:uids => uids, :tpl_id => tpl_id}.merge(opt))
23
+ hashie get("common/send.json", :params => {:uids => uids, :tpl_id => tpl_id}.merge(opt))
24
24
  end
25
25
  end
26
26
  end
@@ -4,7 +4,7 @@ module Weibo
4
4
  class Notification < Base
5
5
  #read interfaces
6
6
  def send(uids, tpl_id, opt={})
7
- hashie get("notification/send", :params => {:uids => uids, :tpl_id => tpl_id}.merge(opt))
7
+ hashie get("notification/send.json", :params => {:uids => uids, :tpl_id => tpl_id}.merge(opt))
8
8
  end
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Weibo
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Weibo
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
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.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: