weibo2 0.1.0

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.
@@ -0,0 +1,20 @@
1
+ Copyright 2011 Acenqiu
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,96 @@
1
+ = Weibo2
2
+
3
+ A Ruby wrapper for Sina weibo API(OAuth2).It is based on {OAuth2 gem}[https://github.com/intridea/oauth2], thanks for his hard-working.I have wrapped most of the APIs sina defined.Note that all of the privilege APIs haven't been tested yet, since I don't get the authorization to use it.
4
+
5
+ == Installation
6
+
7
+ gem install weibo2
8
+
9
+ == Usage Examples
10
+
11
+ Config your api_key, api_secret and redrect_uri somewhere like development.rb.
12
+
13
+ Weibo2::Config.api_key = "1234567890"
14
+ Weibo2::Config.api_secret = "somethinglooksstrageandhardtoremember"
15
+ Weibo2::Config.redirect_uri = "http://www.example.com/callback"
16
+
17
+ Ok, now you are ready to enjoy it. Sina Weibo has provided several ways to get your access token, and you can easily get it using Weibo2.
18
+
19
+ 1.The Authorization Code strategy with response_type set to code
20
+
21
+ # get authorize_url
22
+ client = Weibo2::Client.new
23
+ client.auth_code.authorize_url
24
+ # => "https://api.weibo.com/oauth2/authorize?response_type=code&client_id=1234567890&redirect_uri=http%3A%2F%2Fwww.example.com%2fcallback"
25
+
26
+ # get token using authorization_code
27
+ # Weibo2::Client.from_code is a shortcut for client.auth_code.get_token("authorization_code_value")
28
+ client = Weibo2::Client.from_code("authorization_code_value")
29
+
30
+ 2.The Authorization Code strategy with response_type set to token
31
+
32
+ # get authorize_url with response_type set to token
33
+ client = Weibo::Client.new
34
+ client.auth_code.authorize_url(:response_type => "token")
35
+ # => "https://api.weibo.com/oauth2/authorize?response_type=token&client_id=1234567890&redirect_uri=http%3A%2F%2Fwww.example.com%2fcallback"
36
+
37
+ # get token from callback hash like this /callback#access_token=6874dd3766b35536abcb76a9e3a57867&expires_in=86400
38
+ client = Weibo2::Client.from_hash(:access_token => "6874dd3766b35536abcb76a9e3a57867", :expires_in => 86400)
39
+
40
+ 3.The Resource Owner Password Credentials strategy
41
+
42
+ # get token with user's password
43
+ client = Weibo::Client.new
44
+ client.password.get_token('username', 'password')
45
+
46
+ 4.Signed Request strategy
47
+
48
+ Follow this link to read more about this strategy.{站内应用开发指南}[http://open.weibo.com/wiki/%E7%AB%99%E5%86%85%E5%BA%94%E7%94%A8%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97]
49
+
50
+
51
+ # get token using signed_request
52
+ client = Weibo2::Client.from_signed_request("signed_request-posted-by-weibo")
53
+
54
+ # you can see what the signed_request exactly is by
55
+ client.signed_request.unsigned_request
56
+ # => {"user"=>{"country"=>"cn", "locale"=>""}, "algorithm"=>"HMAC-SHA256", "issued_at"=>1320298983, "expires"=>1320385383, "oauth_token"=>"0ca59d99f92436d65ae23115604a3185", "user_id"=>1234567890}
57
+
58
+ 5.Refresh your token
59
+
60
+ Note that you could refresh your token only when you can get the refresh_token.
61
+
62
+
63
+ client.refresh!
64
+
65
+ You can check if you are authorized by
66
+
67
+ client.is_authorized?
68
+ # => true
69
+
70
+ If you are authorized, then you can do whatever you want now.
71
+
72
+ response = client.account.get_uid
73
+ # => #<OAuth2::Response:: ...>
74
+
75
+ response.parsed
76
+ # => {"uid"=>1234567890}
77
+
78
+
79
+ == API
80
+
81
+ You can find them in /lib/weibo2/interface/.Note that all methods follow the patten of
82
+
83
+ {resource}.{the_rest_path_joined_by_underline}(required_params, opts={})
84
+
85
+ So {/statuses/hot/comments_weekly}[http://open.weibo.com/wiki/2/statuses/hot/comments_weekly] will turn to
86
+
87
+ statuses.hot_comments_weekly(opts={})
88
+
89
+ And {/friendships/friends/in_common}[http://open.weibo.com/wiki/2/friendships/friends/in_common] will turn to
90
+
91
+ friendships.friends_in_common(uid, opts={})
92
+
93
+
94
+ == Copyright
95
+
96
+ Copyright (c) 2011 Acenqiu. See LICENSE for details.
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Weibo2'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :weibo2 do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,17 @@
1
+ require 'weibo2/client'
2
+ require 'weibo2/config'
3
+ require 'weibo2/error'
4
+ require 'weibo2/strategy/auth_code.rb'
5
+ require 'weibo2/strategy/signed_request.rb'
6
+ require 'weibo2/interface/base'
7
+ require 'weibo2/interface/account'
8
+ require 'weibo2/interface/comments'
9
+ require 'weibo2/interface/favorites'
10
+ require 'weibo2/interface/friendships'
11
+ require 'weibo2/interface/register'
12
+ require 'weibo2/interface/search'
13
+ require 'weibo2/interface/statuses'
14
+ require 'weibo2/interface/suggestions'
15
+ require 'weibo2/interface/tags'
16
+ require 'weibo2/interface/trends'
17
+ require 'weibo2/interface/users'
@@ -0,0 +1,186 @@
1
+ require 'oauth2'
2
+
3
+ module Weibo2
4
+
5
+ # The Weibo2::Client class
6
+ class Client < OAuth2::Client
7
+
8
+ attr_reader :redirect_uri
9
+ attr_accessor :token
10
+
11
+ # Initializes a new Client from a signed_request
12
+ #
13
+ # @param [String] code The Authorization Code value
14
+ # @param [Hash] opts the options to create the client with
15
+ # @option opts [Hash] :connection_opts ({}) Hash of connection options to pass to initialize Faraday with
16
+ # @option opts [FixNum] :max_redirects (5) maximum number of redirects to follow
17
+ # @yield [builder] The Faraday connection builder
18
+ def self.from_code(code, opts={}, &block)
19
+ client = self.new(opts, &block)
20
+ client.auth_code.get_token(code)
21
+
22
+ client
23
+ end
24
+
25
+ # Initializes a new Client from a signed_request
26
+ #
27
+ # @param [String] signed_request param posted by Sina
28
+ # @param [Hash] opts the options to create the client with
29
+ # @option opts [Hash] :connection_opts ({}) Hash of connection options to pass to initialize Faraday with
30
+ # @option opts [FixNum] :max_redirects (5) maximum number of redirects to follow
31
+ # @yield [builder] The Faraday connection builder
32
+ def self.from_signed_request(signed_request, opts={}, &block)
33
+ client = self.new(opts, &block)
34
+ client.signed_request.get_token(signed_request)
35
+
36
+ client
37
+ end
38
+
39
+ # Initializes a new Client from a hash
40
+ #
41
+ # @param [Hash] a Hash contains access_token and expires
42
+ # @param [Hash] opts the options to create the client with
43
+ # @option opts [Hash] :connection_opts ({}) Hash of connection options to pass to initialize Faraday with
44
+ # @option opts [FixNum] :max_redirects (5) maximum number of redirects to follow
45
+ # @yield [builder] The Faraday connection builder
46
+ def self.from_hash(hash, opts={}, &block)
47
+ client = self.new(opts, &block)
48
+ client.get_token_from_hash(hash)
49
+
50
+ client
51
+ end
52
+
53
+ # Initializes a new Client
54
+ #
55
+ # @param [Hash] opts the options to create the client with
56
+ # @option opts [Hash] :connection_opts ({}) Hash of connection options to pass to initialize Faraday with
57
+ # @option opts [FixNum] :max_redirects (5) maximum number of redirects to follow
58
+ # @yield [builder] The Faraday connection builder
59
+ def initialize(opts={}, &block)
60
+ id = Weibo2::Config.api_key
61
+ secret = Weibo2::Config.api_secret
62
+ @redirect_uri = Weibo2::Config.redirect_uri
63
+
64
+ options = {:site => "https://api.weibo.com/2/",
65
+ :authorize_url => "/oauth2/authorize",
66
+ :token_url => "/oauth2/access_token",
67
+ :raise_errors => false,
68
+ :ssl => {:verify => false}}.merge(opts)
69
+
70
+ super(id, secret, options, &block)
71
+ end
72
+
73
+ # Whether or not the client is authorized
74
+ #
75
+ # @return [Boolean]
76
+ def is_authorized?
77
+ !!token && !token.expired?
78
+ end
79
+
80
+ # Initializes an AccessToken by making a request to the token endpoint
81
+ #
82
+ # @param [Hash] params a Hash of params for the token endpoint
83
+ # @param [Hash] access token options, to pass to the AccessToken object
84
+ # @return [AccessToken] the initalized AccessToken
85
+ def get_token(params, access_token_opts={})
86
+ params = params.merge(:parse => :json)
87
+ access_token_opts = access_token_opts.merge({:header_format => "OAuth2 %s", :param_name => "access_token"})
88
+
89
+ @token = super(params, access_token_opts)
90
+ end
91
+
92
+ # Initializes an AccessToken from a hash
93
+ #
94
+ # @param [Hash] hash a Hash contains access_token and expires
95
+ # @return [AccessToken] the initalized AccessToken
96
+ def get_token_from_hash(hash)
97
+ access_token = hash.delete('access_token') || hash.delete(:access_token) || hash.delete('oauth_token') || hash.delete(:oauth_token)
98
+ opts = {:expires_at => hash["expires"] || hash[:expires],
99
+ :header_format => "OAuth2 %s",
100
+ :param_name => "access_token"}
101
+
102
+ @token = OAuth2::AccessToken.new(self, access_token, opts)
103
+ end
104
+
105
+ # Refreshes the current Access Token
106
+ #
107
+ # @return [AccessToken] a new AccessToken
108
+ # @note options should be carried over to the new AccessToken
109
+ def refresh!(params={})
110
+ @token = token.refresh!(params)
111
+ end
112
+
113
+ #
114
+ # Strategies
115
+ #
116
+
117
+ # The Authorization Code strategy
118
+ #
119
+ # @see http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-4.1
120
+ def auth_code
121
+ @auth_code ||= Weibo2::Strategy::AuthCode.new(self)
122
+ end
123
+
124
+ # The Resource Owner Password Credentials strategy
125
+ #
126
+ # @see http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-4.3
127
+ def password
128
+ super
129
+ end
130
+
131
+ # The Signed Request Strategy
132
+ #
133
+ # @see http://open.weibo.com/wiki/%E7%AB%99%E5%86%85%E5%BA%94%E7%94%A8%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97
134
+ def signed_request
135
+ @signed_request ||= Weibo2::Strategy::SignedRequest.new(self)
136
+ end
137
+
138
+ #
139
+ # APIs
140
+ #
141
+
142
+ def account
143
+ @account ||= Weibo2::Interface::Account.new(self)
144
+ end
145
+
146
+ def comments
147
+ @comments ||= Weibo2::Interface::Comments.new(self)
148
+ end
149
+
150
+ def favorites
151
+ @favorites ||= Weibo2::Interface::Favorites.new(self)
152
+ end
153
+
154
+ def friendships
155
+ @friendships ||= Weibo2::Interface::Friendships.new(self)
156
+ end
157
+
158
+ def register
159
+ @register ||= Weibo2::Interface::Register.new(self)
160
+ end
161
+
162
+ def search
163
+ @search ||= Weibo2::Interface::Search.new(self)
164
+ end
165
+
166
+ def statuses
167
+ @statuses ||= Weibo2::Interface::Statuses.new(self)
168
+ end
169
+
170
+ def suggestions
171
+ @suggestions ||= Weibo2::Interface::Suggestions.new(self)
172
+ end
173
+
174
+ def tags
175
+ @tags ||= Weibo2::Interface::Tags.new(self)
176
+ end
177
+
178
+ def trends
179
+ @trends ||= Weibo2::Interface::Trends.new(self)
180
+ end
181
+
182
+ def users
183
+ @users ||= Weibo2::Interface::Users.new(self)
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,28 @@
1
+ module Weibo2
2
+ module Config
3
+
4
+ def self.api_key=(val)
5
+ @@api_key = val
6
+ end
7
+
8
+ def self.api_key
9
+ @@api_key
10
+ end
11
+
12
+ def self.api_secret=(val)
13
+ @@api_secret = val
14
+ end
15
+
16
+ def self.api_secret
17
+ @@api_secret
18
+ end
19
+
20
+ def self.redirect_uri=(val)
21
+ @@redirect_uri = val
22
+ end
23
+
24
+ def self.redirect_uri
25
+ @@redirect_uri
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ module Weibo2
2
+ class Error < OAuth2::Error
3
+
4
+ def initialize(response)
5
+ response.error = self
6
+ @response = response
7
+ if response.parsed.is_a?(Hash)
8
+ @code = response.parsed['error_code']
9
+ @description = response.parsed['error']
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,205 @@
1
+ # encoding: utf-8
2
+ module Weibo2
3
+ module Interface
4
+
5
+ # Account API
6
+ #
7
+ # @see http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2#.E8.B4.A6.E5.8F.B7
8
+ class Account < Base
9
+
10
+ # 获取用户基本信息 [Privilege]
11
+ #
12
+ # @param [Hash] opts
13
+ # @option opts [int64] :uid 需要获取基本信息的用户UID,默认为当前登录用户
14
+ #
15
+ # @see http://open.weibo.com/wiki/2/account/profile/basic
16
+ def profile_basic(opts={})
17
+ get 'account/profile/basic.json', :params => opts
18
+ end
19
+
20
+ # 获取用户的教育信息 [Privilege]
21
+ #
22
+ # @param [Hash] opts
23
+ # @option opts [int64] :uid 需要获取教育信息的用户UID,默认为当前登录用户
24
+ #
25
+ # @see http://open.weibo.com/wiki/2/account/profile/education
26
+ def profile_education(opts={})
27
+ get 'account/profile/education.json', :params => opts
28
+ end
29
+
30
+ # 批量获取用户的教育信息 [Privilege]
31
+ #
32
+ # @param [String] uids 需要获取教育信息的用户UID,用半角逗号分隔,最多不超过20
33
+ #
34
+ # @see http://open.weibo.com/wiki/2/account/profile/education_batch
35
+ def profile_education_batch(uids)
36
+ get 'account/profile/education_batch.json', :params => {:uids => uids}
37
+ end
38
+
39
+ # 获取用户的职业信息 [Privilege]
40
+ #
41
+ # @param [Hash] opts
42
+ # @option opts [int64] :uid 需要获取教育信息的用户UID,默认为当前登录用户
43
+ #
44
+ # @see http://open.weibo.com/wiki/2/account/profile/career
45
+ def profile_career(opts={})
46
+ get 'account/profile/career.json', :params => opts
47
+ end
48
+
49
+ # 批量获取用户的职业信息 [Privilege]
50
+ #
51
+ # @param [String] uids 需要获取教育信息的用户UID,用半角逗号分隔,最多不超过20
52
+ #
53
+ # @see http://open.weibo.com/wiki/2/account/profile/career_batch
54
+ def profile_career_batch(uids)
55
+ get 'account/profile/career_batch.json', :params => uids
56
+ end
57
+
58
+ # 获取当前登录用户的隐私设置
59
+ #
60
+ # @see http://open.weibo.com/wiki/2/account/get_privacy
61
+ def get_privacy
62
+ get 'account/get_privacy.json'
63
+ end
64
+
65
+ # 获取所有的学校列表
66
+ #
67
+ # @param [Hash] opts
68
+ # @option opts [int] :province 省份范围,省份ID
69
+ # @option opts [int] :city 城市范围,城市ID
70
+ # @option opts [int] :area 区域范围,区ID
71
+ # @option opts [int] :type 学校类型,1:大学、2:高中、3:中专技校、4:初中、5:小学,默认为1
72
+ # @option opts [String] :capital 学校首字母,默认为A
73
+ # @option opts [String] :keyword 学校名称关键字
74
+ # @option opts [int] :count 返回的记录条数,默认为10
75
+ #
76
+ # @see http://open.weibo.com/wiki/2/account/profile/school_list
77
+ def profile_school_list(opts={})
78
+ get 'account/profile/school_list.json', :params => opts
79
+ end
80
+
81
+ # 获取当前登录用户的API访问频率限制情况
82
+ #
83
+ # @see http://open.weibo.com/wiki/2/account/rate_limit_status
84
+ def rate_limit_status
85
+ get 'account/rate_limit_status.json'
86
+ end
87
+
88
+ # OAuth授权之后,获取授权用户的UID
89
+ #
90
+ # @see http://open.weibo.com/wiki/2/account/get_uid
91
+ def get_uid
92
+ get 'account/get_uid.json'
93
+ end
94
+
95
+ #
96
+ # write
97
+ #
98
+
99
+ # 更新用户的基本信息 [Privilege]
100
+ #
101
+ # @param [String] screen_name 用户昵称,不可为空
102
+ # @param [int] province 省份代码ID,不可为空
103
+ # @param [int] city 城市代码ID,不可为空
104
+ # @param [String] gender 用户性别,m:男、f:女,不可为空
105
+ # @param [Hash] opts
106
+ # @option opts [String] :real_name 用户真实姓名
107
+ # @option opts [int] :real_name_visible 真实姓名可见范围,0:自己可见、1:关注人可见、2:所有人可见
108
+ # @option opts [date] :birthday 用户生日,格式:yyyy-mm-dd
109
+ # @option opts [int] :birthday_visible 生日可见范围,0:保密、1:只显示月日、2:只显示星座、3:所有人可见
110
+ # @option opts [String] :qq 用户QQ号码
111
+ # @option opts [int] :qq_visible 用户QQ可见范围,0:自己可见、1:关注人可见、2:所有人可见
112
+ # @option opts [String] :msn 用户MSN
113
+ # @option opts [int] :msn_visible 用户MSN可见范围,0:自己可见、1:关注人可见、2:所有人可见
114
+ # @option opts [String] :url 用户博客地址
115
+ # @option opts [int] :url_visible 用户博客地址可见范围,0:自己可见、1:关注人可见、2:所有人可见
116
+ # @option opts [int] :credentials_type 证件类型,1:身份证、2:学生证、3:军官证、4:护照
117
+ # @option opts [String] :credentials_num 证件号码
118
+ # @option opts [String] :email 用户常用邮箱地址
119
+ # @option opts [int] :email_visible 用户常用邮箱地址可见范围,0:自己可见、1:关注人可见、2:所有人可见
120
+ # @option opts [String] :lang 语言版本,zh_cn:简体中文、zh_tw:繁体中文
121
+ # @option opts [String] :description 用户描述,最长不超过70个汉字
122
+ #
123
+ # @see http://open.weibo.com/wiki/2/account/profile/basic_update
124
+ def profile_basic_update(screen_name, province, city, gender, opts={})
125
+ body = {:screen_name => screen_name, :province => province, :city => city, :gender => gender}.merge(opts)
126
+ post 'account/profile/basic_update.json', :body => body
127
+ end
128
+
129
+ # 更新当前登录用户的教育信息 [Privilege]
130
+ #
131
+ # @param [int] type 学校类型,1:大学、2:高中、3:中专技校、4:初中、5:小学,默认为1
132
+ # @param [int] school_id 学校代码
133
+ # @param [Hash] opts
134
+ # @option opts [String] :id 需要修改的教育信息ID,不传则为新建,传则为更新
135
+ # @option opts [int] :year 入学年份,最小为1900,最大不超过当前年份
136
+ # @option opts [String] :department 院系或者班别
137
+ # @option opts [int] :visible 开放等级,0:仅自己可见、1:关注的人可见、2:所有人可见
138
+ #
139
+ # @see http://open.weibo.com/wiki/2/account/profile/edu_update
140
+ def profile_edu_update(type, school_id, opts={})
141
+ post 'account/profile/edu_update.json', :body => {:type => type, :school_id => school_id}.merge(opts)
142
+ end
143
+
144
+ # 根据学校ID删除用户的教育信息 [Privilege]
145
+ #
146
+ # @param [int64] id 教育信息里的学校ID
147
+ #
148
+ # @see http://open.weibo.com/wiki/2/account/profile/edu_destroy
149
+ def profile_edu_destroy(id)
150
+ post 'account/profile/edu_destroy.json', :body => {:id => id}
151
+ end
152
+
153
+ # 更新当前登录用户的职业信息 [Privilege]
154
+ #
155
+ # @param [Hash] opts
156
+ # @option opts [String] :id 需要更新的职业信息ID
157
+ # @option opts [int] :start 进入公司年份,最小为1900,最大为当年年份
158
+ # @option opts [int] :end 离开公司年份,至今填0
159
+ # @option opts [String] :department 工作部门
160
+ # @option opts [int] :visible 可见范围,0:自己可见、1:关注人可见、2:所有人可见
161
+ # @option opts [int] :province 省份代码ID,不可为空值
162
+ # @option opts [int] :city 城市代码ID,不可为空值
163
+ # @option opts [String] :company 公司名称,不可为空值
164
+ #
165
+ # @see http://open.weibo.com/wiki/2/account/profile/car_update
166
+ def profile_car_update(opts)
167
+ post 'account/profile/car_update.json', :body => opts
168
+ end
169
+
170
+ # 根据公司ID删除用户的职业信息 [Privilege]
171
+ #
172
+ # @param [int64] id 职业信息里的公司ID
173
+ #
174
+ # @see http://open.weibo.com/wiki/2/account/profile/car_destroy
175
+ def profile_car_destroy(id)
176
+ post 'account/profile/car_destroy.json', :body => {:id => id}
177
+ end
178
+
179
+ # no test
180
+ # 更新当前登录用户的头像 [Privilege]
181
+ #
182
+ # @param [binary] image 头像图片,仅支持JPEG、GIF、PNG格式,图片大小小于5M.必须使用multipart/form-data方式提交
183
+ #
184
+ # @see http://open.weibo.com/wiki/2/account/avatar/upload
185
+ def avatar_upload(image)
186
+ post 'account/avatar/upload.json', :body => {:image => image}
187
+ end
188
+
189
+ # 更新当前登录用户的隐私设置 [Privilege]
190
+ #
191
+ # @param [Hash] opts
192
+ # @option opts [int] :comment 是否可以评论我的微博,0:所有人、1:关注的人,默认为0
193
+ # @option opts [int] :geo 是否开启地理信息,0:不开启、1:开启,默认为1
194
+ # @option opts [int] :message 是否可以给我发私信,0:所有人、1:关注的人,默认为0
195
+ # @option opts [int] :realname 是否可以通过真名搜索到我,0:不可以、1:可以,默认为0
196
+ # @option opts [int] :badge 勋章是否可见,0:不可见、1:可见,默认为1
197
+ # @option opts [int] :mobile 是否可以通过手机号码搜索到我,0:不可以、1:可以,默认为0
198
+ #
199
+ # @see http://open.weibo.com/wiki/2/account/update_privacy
200
+ def update_privacy(opts={})
201
+ post 'account/update_privacy.json', :body => opts
202
+ end
203
+ end
204
+ end
205
+ end