weibo_focus 1.1.1 → 1.1.2

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/example/weibo.rb~ ADDED
@@ -0,0 +1,5 @@
1
+ require "weibo_focus"
2
+
3
+ puts Weibo::VERSION
4
+ Weibo::Config.api_key = "12345678"
5
+ puts Weibo::Config.api_key
@@ -0,0 +1,64 @@
1
+ module Weibo
2
+ module Api
3
+ module V2
4
+ class Friendships < Base
5
+
6
+ #read interfaces
7
+ def friends(opt={})
8
+ get("friendships/friends.json", :params => opt)
9
+ end
10
+
11
+ def friends_in_common(uid, opt={})
12
+ get("friendships/friends/in_common.json", :params => {:uid => uid}.merge(opt))
13
+ end
14
+
15
+ def friends_bilateral(uid, opt={})
16
+ get("friendships/friends/bilateral.json", :params => {:uid => uid}.merge(opt))
17
+ end
18
+
19
+ def friends_bilateral_ids(uid, opt={})
20
+ get("friendships/friends/bilateral/ids.json", :params => {:uid => uid}.merge(opt))
21
+ end
22
+
23
+ def friends_ids(opt={})
24
+ get("friendships/friends/ids.json", :params => opt)
25
+ end
26
+
27
+ def followers(opt={})
28
+ get("friendships/followers.json", :params => opt)
29
+ end
30
+
31
+ def followers_ids(opt={})
32
+ get("friendships/followers/ids.json", :params => opt)
33
+ end
34
+
35
+ def followers_active(uid, opt={})
36
+ get("friendships/followers/active.json", :params => {:uid => uid}.merge(opt))
37
+ end
38
+
39
+ def friends_chain_followers(uid, opt={})
40
+ get("friendships/friends_chain/followers.json", :params => {:uid => uid}.merge(opt))
41
+ end
42
+
43
+ def show(opt={})
44
+ get("friendships/show.json", :params => opt)
45
+ end
46
+
47
+
48
+ #write interfaces
49
+ def create(opt={})
50
+ hashie post("friendships/create.json", :params => opt)
51
+ end
52
+
53
+ def destroy(opt={})
54
+ hashie post("friendships/destroy.json", :params => opt)
55
+ end
56
+
57
+ def remark_update(uid, remark, opt={})
58
+ hashie post("friendships/remark/update.json", :params => {:uid => uid, :remark => remark}.merge(opt))
59
+ end
60
+
61
+ end
62
+ end
63
+ end
64
+ end
@@ -86,6 +86,10 @@ module Weibo
86
86
  @short_url ||= Weibo::Api::V2::ShortUrl.new(@access_token) if @access_token
87
87
  end
88
88
 
89
+ def common
90
+ @common ||= Weibo::Api::V2::Common.new(@access_token) if @access_token
91
+ end
92
+
89
93
  def suggestions
90
94
  @suggestions ||= Weibo::Api::V2::Suggestions.new(@access_token) if @access_token
91
95
  end
@@ -94,6 +98,18 @@ module Weibo
94
98
  @remind ||= Weibo::Api::V2::Remind.new(@access_token) if @access_token
95
99
  end
96
100
 
101
+ def place
102
+ @place ||= Weibo::Api::V2::Place.new(@access_token) if @access_token
103
+ end
104
+
105
+ def notification
106
+ @notification ||= Weibo::Api::V2::Notification.new(@access_token) if @access_token
107
+ end
108
+
109
+ def location
110
+ @location ||= Weibo::Api::V2::Location.new(@access_token) if @access_token
111
+ end
112
+
97
113
  def auth_code
98
114
  @auth_code ||= Weibo::Strategy::AuthCode.new(self)
99
115
  end
@@ -0,0 +1,118 @@
1
+ require 'oauth2'
2
+
3
+ module Weibo
4
+ class Client < OAuth2::Client
5
+
6
+ def initialize(client_id='', client_secret='', opts={}, &block)
7
+ client_id = Weibo::Config.api_key if client_id.empty?
8
+ client_secret = Weibo::Config.api_secret if client_secret.empty?
9
+ super
10
+ @site = "https://api.weibo.com/2/"
11
+ @options[:authorize_url] = '/oauth2/authorize'
12
+ @options[:token_url] = '/oauth2/access_token'
13
+ end
14
+
15
+ def authorize_url(params={})
16
+ params[:client_id] = @id unless params[:client_id]
17
+ params[:response_type] = 'code' unless params[:response_type]
18
+ params[:redirect_uri] = Weibo::Config.redirect_uri unless params[:redirect_uri]
19
+ super
20
+ end
21
+
22
+ def get_token(params, access_token_opts={})
23
+ params = params.merge({:parse => :json})
24
+ access_token_opts = access_token_opts.merge({:header_format => "OAuth2 %s", :param_name => "access_token"})
25
+ super
26
+ end
27
+
28
+ def get_and_restore_token(params, access_token_opts={})
29
+ @access_token = get_token(params, access_token_opts={})
30
+ end
31
+
32
+ def get_token_from_hash(hash)
33
+ access_token = hash.delete(:access_token) || hash.delete('access_token')
34
+ opts = {:expires_at => (hash.delete(:expires_at) || hash.delete('expires_at')),
35
+ :header_format => "OAuth2 %s",
36
+ :param_name => "access_token"}
37
+
38
+ @access_token = Weibo::AccessToken.new(self, access_token, opts)
39
+ end
40
+
41
+ def authorized?
42
+ !!@access_token
43
+ end
44
+
45
+ def users
46
+ @users ||= Weibo::Api::V2::Users.new(@access_token) if @access_token
47
+ end
48
+
49
+ def statuses
50
+ @statues ||= Weibo::Api::V2::Statuses.new(@access_token) if @access_token
51
+ end
52
+
53
+ def comments
54
+ @comments ||= Weibo::Api::V2::Comments.new(@access_token) if @access_token
55
+ end
56
+
57
+ def friendships
58
+ @friendships ||= Weibo::Api::V2::Friendships.new(@access_token) if @access_token
59
+ end
60
+
61
+ def account
62
+ @account ||= Weibo::Api::V2::Account.new(@access_token) if @access_token
63
+ end
64
+
65
+ def favorites
66
+ @favorites ||= Weibo::Api::V2::Favorites.new(@access_token) if @access_token
67
+ end
68
+
69
+ def trends
70
+ @trends ||= Weibo::Api::V2::Trends.new(@access_token) if @access_token
71
+ end
72
+
73
+ def tags
74
+ @tags ||= Weibo::Api::V2::Tags.new(@access_token) if @access_token
75
+ end
76
+
77
+ def register
78
+ @register ||= Weibo::Api::V2::Register.new(@access_token) if @access_token
79
+ end
80
+
81
+ def search
82
+ @search ||= Weibo::Api::V2::Search.new(@access_token) if @access_token
83
+ end
84
+
85
+ def short_url
86
+ @short_url ||= Weibo::Api::V2::ShortUrl.new(@access_token) if @access_token
87
+ end
88
+
89
+ def common
90
+ @common ||= Weibo::Api::V2::Common.new(@access_token) if @access_token
91
+ end
92
+
93
+ def suggestions
94
+ @suggestions ||= Weibo::Api::V2::Suggestions.new(@access_token) if @access_token
95
+ end
96
+
97
+ def remind
98
+ @remind ||= Weibo::Api::V2::Remind.new(@access_token) if @access_token
99
+ end
100
+
101
+ def place
102
+ @place ||= Weibo::Api::V2::Place.new(@access_token) if @access_token
103
+ end
104
+
105
+ def notification
106
+ @notification ||= Weibo::Api::V2::Notification.new(@access_token) if @access_token
107
+ end
108
+
109
+ def location
110
+ @location ||= Weibo::Api::V2::Location.new(@access_token) if @access_token
111
+ end
112
+
113
+ def auth_code
114
+ @auth_code ||= Weibo::Strategy::AuthCode.new(self)
115
+ end
116
+
117
+ end
118
+ end
@@ -1,3 +1,3 @@
1
1
  module Weibo
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Weibo
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
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.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
12
+ date: 2012-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -105,6 +105,7 @@ files:
105
105
  - Rakefile
106
106
  - example/.sass-cache/0d4365dd4f25a1b2574fe0fe2e903692b6df08f1/screen.sassc
107
107
  - example/.sass-cache/80b2331c862c6e430e0af18caf62d12d982610f0/screen.sassc
108
+ - example/.sass-cache/ae31931285d2de3d4538afeb5c53b2d27dc56656/screen.sassc
108
109
  - example/.sass-cache/faf9751221db0b5ce76d45351b9591c3bfc59441/screen.sassc
109
110
  - example/Gemfile
110
111
  - example/Gemfile~
@@ -115,6 +116,7 @@ files:
115
116
  - example/views/layout.haml
116
117
  - example/views/screen.sass
117
118
  - example/weibo.rb
119
+ - example/weibo.rb~
118
120
  - lib/weibo_focus.rb
119
121
  - lib/weibo_focus.rb~
120
122
  - lib/weibo_focus/access_token.rb
@@ -124,6 +126,7 @@ files:
124
126
  - lib/weibo_focus/api/v2/common.rb
125
127
  - lib/weibo_focus/api/v2/favorites.rb
126
128
  - lib/weibo_focus/api/v2/friendships.rb
129
+ - lib/weibo_focus/api/v2/friendships.rb~
127
130
  - lib/weibo_focus/api/v2/location.rb
128
131
  - lib/weibo_focus/api/v2/notification.rb
129
132
  - lib/weibo_focus/api/v2/place.rb
@@ -138,6 +141,7 @@ files:
138
141
  - lib/weibo_focus/api/v2/users.rb
139
142
  - lib/weibo_focus/base.rb
140
143
  - lib/weibo_focus/client.rb
144
+ - lib/weibo_focus/client.rb~
141
145
  - lib/weibo_focus/config.rb
142
146
  - lib/weibo_focus/config.rb~
143
147
  - lib/weibo_focus/oauth.rb