Class: QqClient::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/qq_client/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ Client

Returns a new instance of Client.



7
8
9
# File 'lib/qq_client/client.rb', line 7

def initialize(access_token)
	@oauth = Oauth.new(access_token)
end

Instance Attribute Details

#oauthObject (readonly)

Returns the value of attribute oauth.



5
6
7
# File 'lib/qq_client/client.rb', line 5

def oauth
  @oauth
end

Instance Method Details

#add_blog(uid, title, content) ⇒ Object



35
36
37
38
# File 'lib/qq_client/client.rb', line 35

def add_blog(uid, title, content)
	params = { :content => content,:title => title,:format => 'json' }
	@oauth.post uid, "blog/add_one_blog", params
end

#add_pic_t(uid, content, pic, options = {}) ⇒ Object

Upload a picture and posted a message on the Tencent microblogging platforms. More info (wiki.connect.qq.com/add_pic_t)



30
31
32
33
# File 'lib/qq_client/client.rb', line 30

def add_pic_t(uid, content, pic, options = {})
	default_params = { :content => content, :pic => pic, :multipart => true }
	@oauth.post uid, "t/add_pic_t", default_params.merge(options)
end

#add_t(uid, content, options = {}) ⇒ Object

Published a microblogging message (plain text) to the Tencent microblogging platforms. More info (wiki.connect.qq.com/add_t)



23
24
25
26
# File 'lib/qq_client/client.rb', line 23

def add_t(uid, content, options = {})
	default_params = { :content => content }
	@oauth.post uid, "t/add_t", default_params.merge(options)
end

#get_info(uid, options = {}) ⇒ Object

Get Tencent Weibo user’s login information. More info (wiki.connect.qq.com/get_info)



15
16
17
18
19
# File 'lib/qq_client/client.rb', line 15

def get_info(uid, options = {})
	data = @oauth.post uid, "user/get_info", options
	data['data']['openid'] = uid
	data
end

#get_uidObject



40
41
42
43
# File 'lib/qq_client/client.rb', line 40

def get_uid
	default_params = { :format => 'json' }
	@oauth.get_uid "oauth2.0/me", default_params
end