Class: Weibo2::Interface::Tags

Inherits:
Base
  • Object
show all
Defined in:
lib/weibo2/interface/tags.rb

Overview

Tags API

Instance Method Summary collapse

Methods inherited from Base

#get, #initialize, #post, #request

Constructor Details

This class inherits a constructor from Weibo2::Interface::Base

Instance Method Details

#create(tags) ⇒ Object

为当前登录用户添加新的用户标签

Parameters:

  • tags (String)

    要创建的一组标签,用半角逗号隔开,每个标签的长度不可超过7个汉字,14个半角字符

See Also:



49
50
51
# File 'lib/weibo2/interface/tags.rb', line 49

def create(tags)
  post 'tags/create.json', :body => {:tags => tags}
end

#destroy(tag_id) ⇒ Object

删除一个用户标签

Parameters:

  • tag_id (int64)

    要删除的标签ID

See Also:



58
59
60
# File 'lib/weibo2/interface/tags.rb', line 58

def destroy(tag_id)
  post 'tags/destroy.json', :body => {:tag_id => tag_id}
end

#destroy_batch(ids) ⇒ Object

批量删除一组标签

Parameters:

  • ids (String)

    要删除的一组标签ID,以半角逗号隔开,一次最多提交10个ID



66
67
68
# File 'lib/weibo2/interface/tags.rb', line 66

def destroy_batch(ids)
  post 'tags/destroy_batch.json', :body => {:ids => ids}
end

#suggestions(opts = {}) ⇒ Object

获取系统推荐的标签列表

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :count (int)

    返回记录数,默认10,最大10

See Also:



36
37
38
# File 'lib/weibo2/interface/tags.rb', line 36

def suggestions(opts={})
  get 'tags/suggestions.json', :params => opts
end

#tags(uid, opts = {}) ⇒ Object

返回指定用户的标签列表

Parameters:

  • uid (int64)

    要获取的标签列表所属的用户ID

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :count (int)

    单页返回的记录条数,默认为20

  • :page (int)

    返回结果的页码,默认为1

See Also:



17
18
19
# File 'lib/weibo2/interface/tags.rb', line 17

def tags(uid, opts={})
  get 'tags.json', :params => {:uid => uid}.merge(opts)
end

#tags_batch(uids) ⇒ Object

批量获取用户的标签列表

Parameters:

  • uids (String)

    要获取标签的用户ID。最大20,逗号分隔

See Also:



26
27
28
# File 'lib/weibo2/interface/tags.rb', line 26

def tags_batch(uids)
  get 'tags/tags_batch.json', :params => {:uids => uids}
end