Class: SaeClient2

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, secret, access_token, refresh_token, weibo_uid = nil) ⇒ SaeClient2

Returns a new instance of SaeClient2.



4
5
6
7
# File 'lib/sae_client2.rb', line 4

def initialize(key, secret, access_token, refresh_token, weibo_uid = nil)
  @oauth = SaeOauth2.new(key, secret, access_token, refresh_token)
  @weibo_uid = weibo_uid
end

Instance Attribute Details

#oauthObject (readonly)

Returns the value of attribute oauth.



2
3
4
# File 'lib/sae_client2.rb', line 2

def oauth
  @oauth
end

Instance Method Details

#create_friendshipObject



25
26
27
# File 'lib/sae_client2.rb', line 25

def create_friendship
  self.oauth.post("https://api.weibo.com/2/friendships/create.json", {:uid  => @weibo_uid})
end

#followers(cursor = -1,, count = 200) ⇒ Object



17
18
19
# File 'lib/sae_client2.rb', line 17

def followers(cursor = -1, count = 200)
  self.oauth.get("https://api.weibo.com/2/friendships/followers.json", {:cursor => cursor, :count => count, :uid => @weibo_uid})
end

#friends(cursor = -1,, count = 200) ⇒ Object



21
22
23
# File 'lib/sae_client2.rb', line 21

def friends(cursor = -1, count = 200)
  self.oauth.get("https://api.weibo.com/2/friendships/friends.json", {:cursor => cursor, :count => count, :uid => @weibo_uid})
end

#tagsObject



33
34
35
# File 'lib/sae_client2.rb', line 33

def tags
  self.oauth.get("https://api.weibo.com/2/tags.json", {:uid => @weibo_uid})
end

#update(status) ⇒ Object



9
10
11
# File 'lib/sae_client2.rb', line 9

def update(status)
  self.oauth.post("https://api.weibo.com/2/statuses/update.json", {:status  => status})
end

#upload(status, pic_path, lat = nil, long = nil) ⇒ Object



13
14
15
# File 'lib/sae_client2.rb', line 13

def upload(status, pic_path, lat = nil, long = nil)
  self.oauth.post('https://api.weibo.com/2/statuses/upload.json', {:status => status, :pic => File.new(File.expand_path(pic_path))})
end

#user_timelineObject



37
38
39
# File 'lib/sae_client2.rb', line 37

def user_timeline
  self.oauth.get("https://api.weibo.com/2/statuses/user_timeline.json", {:uid => @weibo_uid})
end

#users_showObject



29
30
31
# File 'lib/sae_client2.rb', line 29

def users_show
  self.oauth.get("https://api.weibo.com/2/users/show.json", {:uid => @weibo_uid})
end