class WeiboSina::Weibo

To change this template use File | Settings | File Templates.

Attributes

access_token[R]

Public Class Methods

new(access_token) click to toggle source
# File lib/weibo_sina/weibo.rb, line 12
def initialize(access_token)
  @access_token = access_token
end

Public Instance Methods

domain_show(domain) click to toggle source

根据用户个性域名获取用户信息

# File lib/weibo_sina/weibo.rb, line 88
def domain_show(domain)
  url = "https://api.weibo.com/2/users/domain_show.json"
  args ={}
  args.merge!(access_token:@access_token)
  args.merge!(domain:domain)
  base = Base.new()
  return JSON.parse(base.https_get(url,args))
end
friendship_create(uid) click to toggle source

关注某人

# File lib/weibo_sina/weibo.rb, line 78
def friendship_create(uid)
  url = "https://api.weibo.com/2/friendships/create.json"
  args ={}
  args.merge!(access_token:@access_token)
  args.merge!(uid:uid)
  base = Base.new()
  return JSON.parse(base.https_post(url,args))
end
friendship_create_by_domain(domain) click to toggle source

根据用户个性域名关注某人

# File lib/weibo_sina/weibo.rb, line 98
def friendship_create_by_domain(domain)
   user = domain_show(domain)
   return friendship_create(user["id"])
end
get_friends_timeline(feature=1) click to toggle source

获取朋友的动态

# File lib/weibo_sina/weibo.rb, line 67
def get_friends_timeline(feature=1)
  url = "https://api.weibo.com/2/statuses/friends_timeline.json"
  args ={}
  args.merge!(access_token:@access_token)
  args.merge!(feature:feature)
  args.merge!(count:100)
  base = Base.new()
  return JSON.parse(base.https_get(url,args))["statuses"]
end
get_friends_timeline_ids(feature=1) click to toggle source
# File lib/weibo_sina/weibo.rb, line 63
def get_friends_timeline_ids(feature=1)
end
get_home_time(feature=1) click to toggle source

获取当前登录用户的动态列表

# File lib/weibo_sina/weibo.rb, line 52
def get_home_time(feature=1)
  url = "https://api.weibo.com/2/statuses/home_timeline.json"
  args ={}
  args.merge!(access_token:@access_token)
  args.merge!(feature:feature)
  args.merge!(count:100)
  base = Base.new()
  return JSON.parse(base.https_get(url,args))["statuses"]
end
get_uid_friends(screen_name,count=500) click to toggle source

用户关注的UID列表

# File lib/weibo_sina/weibo.rb, line 28
def get_uid_friends(screen_name,count=500)
  url = "https://api.weibo.com/2/friendships/friends/ids.json"
  args = {}
  args.merge!(access_token:@access_token)
  args.merge!(screen_name:screen_name)
  args.merge!(count:count)
  base = Base.new()
  return JSON.parse(base.https_get(url,args))["ids"]
end
get_user_timelines_ids(uid,feature=1) click to toggle source

获取指定用于的微博ID列表 uid 指定的用户ID feature 微博类型 0:全部、1:原创、2:图片、3:视频、4:音乐

# File lib/weibo_sina/weibo.rb, line 41
def get_user_timelines_ids(uid,feature=1)
  url = "https://api.weibo.com/2/statuses/user_timeline/ids.json"
  args ={}
  args.merge!(access_token:@access_token)
  args.merge!(uid:uid)
  args.merge!(feature:feature)
  base = Base.new()
  return JSON.parse(base.https_get(url,args))["statuses"]
end
get_weibo_by_id(id) click to toggle source

根据微博ID获取单条微博内容

# File lib/weibo_sina/weibo.rb, line 17
def get_weibo_by_id(id)
  url = "https://api.weibo.com/2/statuses/show.json"
  args = {}
  args.merge!(access_token:@access_token)
  args.merge!(id:id)
  base = Base.new()
  return JSON.parse(base.https_get(url,args))
end