renren2 1.0.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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +81 -0
- data/Rakefile +26 -0
- data/lib/renren2.rb +20 -0
- data/lib/renren2/client.rb +220 -0
- data/lib/renren2/config.rb +28 -0
- data/lib/renren2/interface/admin.rb +32 -0
- data/lib/renren2/interface/base.rb +54 -0
- data/lib/renren2/interface/blog.rb +89 -0
- data/lib/renren2/interface/checkins.rb +27 -0
- data/lib/renren2/interface/feed.rb +47 -0
- data/lib/renren2/interface/friends.rb +100 -0
- data/lib/renren2/interface/invitations.rb +40 -0
- data/lib/renren2/interface/like.rb +54 -0
- data/lib/renren2/interface/notifications.rb +44 -0
- data/lib/renren2/interface/pages.rb +126 -0
- data/lib/renren2/interface/pay.rb +66 -0
- data/lib/renren2/interface/photos.rb +178 -0
- data/lib/renren2/interface/places.rb +40 -0
- data/lib/renren2/interface/requests.rb +25 -0
- data/lib/renren2/interface/share.rb +58 -0
- data/lib/renren2/interface/status.rb +108 -0
- data/lib/renren2/interface/users.rb +62 -0
- data/lib/renren2/strategy/auth_code.rb +28 -0
- data/lib/renren2/version.rb +3 -0
- data/lib/tasks/renren2_tasks.rake +4 -0
- metadata +104 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
module Renren2
|
2
|
+
module Interface
|
3
|
+
|
4
|
+
# Blog Interface
|
5
|
+
#
|
6
|
+
# @see http://wiki.dev.renren.com/wiki/API
|
7
|
+
class Blog < Base
|
8
|
+
|
9
|
+
# 创建一篇日志
|
10
|
+
#
|
11
|
+
# @param [String] title 日志的标题
|
12
|
+
# @param [String] content 日志的内容
|
13
|
+
# @param [Hash] opts
|
14
|
+
# @option opts [int] :visible 日志的隐私设置,可用值有99(所有人可见)1(仅好友可见)4(需要密码)-1(仅自己可见),错传或没传,默认为99
|
15
|
+
# @option opts [String] :password 用户设置的密码
|
16
|
+
# @note require "publish_blog" scope
|
17
|
+
#
|
18
|
+
# @see http://wiki.dev.renren.com/wiki/Blog.addBlog
|
19
|
+
def add_blog(title, content, opts={})
|
20
|
+
check_scope "publish_blog"
|
21
|
+
post 'blog.addBlog', :body => {:title => title, :content => content}.merge(opts)
|
22
|
+
end
|
23
|
+
|
24
|
+
# 获取指定用户的可见日志信息列表
|
25
|
+
#
|
26
|
+
# @param [int64] uid 用户的ID
|
27
|
+
# @param [Hash] opts
|
28
|
+
# @option opts [int] :page 分页的页数,默认值为1
|
29
|
+
# @option opts [int] :count 每页显示的日志的数量, 缺省值为20
|
30
|
+
# @note require "read_user_blog" scope
|
31
|
+
#
|
32
|
+
# @see http://wiki.dev.renren.com/wiki/Blog.gets
|
33
|
+
def gets(uid, opts={})
|
34
|
+
check_scope "read_user_blog"
|
35
|
+
post 'blog.gets', :body => {:uid => uid}.merge(opts)
|
36
|
+
end
|
37
|
+
|
38
|
+
# 获取自己或好友一篇日志的信息
|
39
|
+
#
|
40
|
+
# @param [String] id 日志id
|
41
|
+
# @param [int64] uid 日志所有者的ID或公共主页的ID
|
42
|
+
# @param [Hash] opts
|
43
|
+
# @option opts [int] :comment 返回评论内容,最大值为50,默认值0
|
44
|
+
# @option opts [String] :password 日志的密码(当日志有密码时
|
45
|
+
# @note require "read_user_blog" scope
|
46
|
+
#
|
47
|
+
# @see http://wiki.dev.renren.com/wiki/Blog.get
|
48
|
+
def get(id, uid, opts={})
|
49
|
+
check_scope "read_user_blog"
|
50
|
+
post 'blog.get', :body => {:id => id, :uid => uid}.merge(opts)
|
51
|
+
end
|
52
|
+
|
53
|
+
# 获取一篇日志的评论
|
54
|
+
#
|
55
|
+
# @param [String] id 日志id
|
56
|
+
# @param [int64] uid 日志所有者的ID或公共主页的ID
|
57
|
+
# @param [Hash] opts
|
58
|
+
# @option opts [int] :page 分页的页数,默认值为1
|
59
|
+
# @option opts [int] :count 每页所包含的评论数,默认值为20, 最大值为50
|
60
|
+
# @option opts [int] :order 排序方式。1:代表逆序;0:正序。默认值为0
|
61
|
+
# @note require "read_user_blog,read_user_comment" scope
|
62
|
+
#
|
63
|
+
# @see http://wiki.dev.renren.com/wiki/Blog.getComments
|
64
|
+
def get_comments(id, uid, opts={})
|
65
|
+
check_scope "read_user_blog"
|
66
|
+
check_scope "read_user_comment"
|
67
|
+
post 'blog.getComments', :body => {:id => id, :uid => uid}.merge(opts)
|
68
|
+
end
|
69
|
+
|
70
|
+
# 发布一个人人网日志的评论
|
71
|
+
#
|
72
|
+
# @param [String] id 日志id
|
73
|
+
# @param [int64] uid 日志所有者的ID或公共主页的ID
|
74
|
+
# @param [String] content 评论的内容
|
75
|
+
# @param [Hash] opts
|
76
|
+
# @option opts [int] :rid 用于二级回复,被回复的人的用户ID
|
77
|
+
# @option opts [int] :type 是否为悄悄话,1表示悄悄话,0表示公开评论
|
78
|
+
# @note require "publish_blog,publish_comment" scope
|
79
|
+
#
|
80
|
+
# @see http://wiki.dev.renren.com/wiki/Blog.addComment
|
81
|
+
def add_comment(id, uid, content, opts={})
|
82
|
+
check_scope "publish_blog"
|
83
|
+
check_scope "publish_comment"
|
84
|
+
post 'blog.addComment', :body => {:id => id, :uid => uid, :content => content}.merge(opts)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Renren2
|
2
|
+
module Interface
|
3
|
+
|
4
|
+
# Checkins Interface
|
5
|
+
#
|
6
|
+
# @see http://wiki.dev.renren.com/wiki/API
|
7
|
+
class Checkins < Base
|
8
|
+
|
9
|
+
# 签到
|
10
|
+
#
|
11
|
+
# @param [String] place_id 签到地点的ID
|
12
|
+
# @param [Hash] opts
|
13
|
+
# @option opts [String] :message 签到时发布的内容
|
14
|
+
# @option opts [double] :longitude 地点的经度,有效范围-180.0到+180.0,“+”表示东经
|
15
|
+
# @option opts [double] :latitude 地点的纬度,有效范围-90.0到+90.0,“+”表示北纬
|
16
|
+
# @option opts [int] :privacy 隐私设置。“0”表示所有人可见,“1”仅自己可见。默认“0”为所有人可见
|
17
|
+
# @note require "publish_checkin" scope
|
18
|
+
#
|
19
|
+
# @see http://wiki.dev.renren.com/wiki/Checkins.checkin
|
20
|
+
def checkin(place_id, opts={})
|
21
|
+
check_scope "publish_checkin"
|
22
|
+
post 'checkins.checkin', :body => {:place_id => place_id}.merge(opts)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# test passed: 2011-11-06 14:49:26
|
3
|
+
module Renren2
|
4
|
+
module Interface
|
5
|
+
|
6
|
+
# Feed Interface
|
7
|
+
#
|
8
|
+
# @see http://wiki.dev.renren.com/wiki/API
|
9
|
+
class Feed < Base
|
10
|
+
|
11
|
+
# 获取当前用户的新鲜事内容
|
12
|
+
#
|
13
|
+
# @param [String] type 新鲜事的类别,多个类型以逗号分隔(http://wiki.dev.renren.com/wiki/Type%E5%88%97%E8%A1%A8)
|
14
|
+
# @param [Hash] opts
|
15
|
+
# @option opts [int] :uid 支持传入当前用户的一个好友ID,表示获取此好友的新鲜事,如果不传,默认为获取当前用户的新鲜事
|
16
|
+
# @option opts [int] :page 支持分页,指定页号,页号从1开始,默认值为1
|
17
|
+
# @option opts [int] :count 支持分页,每一页记录数,默认值为30,最大50
|
18
|
+
# @note require "read_user_feed" scope
|
19
|
+
#
|
20
|
+
# @see http://wiki.dev.renren.com/wiki/Feed.get
|
21
|
+
def get(type, opts={})
|
22
|
+
check_scope "read_user_feed"
|
23
|
+
post 'feed.get', :body => {:type => type}.merge(opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
# 以当前会话的用户(session_key对应用户)身份发送应用的自定义新鲜事
|
27
|
+
#
|
28
|
+
# @param [String] name 新鲜事标题 注意:最多30个字符
|
29
|
+
# @param [String] description 新鲜事主体内容 注意:最多200个字符
|
30
|
+
# @param [String] url 新鲜事标题和图片指向的链接
|
31
|
+
# @option opts [String] :image 新鲜事图片地址
|
32
|
+
# @option opts [String] :caption 新鲜事副标题 注意:最多20个字符
|
33
|
+
# @option opts [String] :action_name 新鲜事动作模块文案。 注意:最多10个字符
|
34
|
+
# @option opts [String] :action_link 新鲜事动作模块链接
|
35
|
+
# @option opts [String] :message 用户输入的自定义内容。注意:最多200个字符
|
36
|
+
# @note require "publish_feed" scope
|
37
|
+
#
|
38
|
+
# @see http://wiki.dev.renren.com/wiki/Feed.publishFeed
|
39
|
+
def publish_feed(name, description, url, opts={})
|
40
|
+
check_scope "publish_feed"
|
41
|
+
post 'feed.publishFeed', :body => {:name => name, :description => description, :url => url}.merge(opts)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# test passed: 2011-11-06 15:22:49
|
3
|
+
module Renren2
|
4
|
+
module Interface
|
5
|
+
|
6
|
+
# Friends Interface
|
7
|
+
#
|
8
|
+
# @see http://wiki.dev.renren.com/wiki/API
|
9
|
+
class Friends < Base
|
10
|
+
|
11
|
+
# 判断两组用户是否互为好友关系,比较的两组用户数必须相等
|
12
|
+
#
|
13
|
+
# @param [String] uids1 第一组用户的ID,每个ID之间以逗号分隔
|
14
|
+
# @param [String] uids2 第二组用户的ID,每个ID之间以逗号分隔
|
15
|
+
#
|
16
|
+
# @see http://wiki.dev.renren.com/wiki/Friends.areFriends
|
17
|
+
def are_friends(uids1, uids2)
|
18
|
+
post 'friends.areFriends', :body => {:uids1 => uids1, :uids2 => uids2}
|
19
|
+
end
|
20
|
+
|
21
|
+
# 得到当前登录用户的好友列表,得到的只是含有好友uid的列表
|
22
|
+
#
|
23
|
+
# @param [Hash] opts
|
24
|
+
# @option opts [int] :page 分页,默认为1
|
25
|
+
# @option opts [int] :count 返回每页个数,默认为500
|
26
|
+
#
|
27
|
+
# @see http://wiki.dev.renren.com/wiki/Friends.get
|
28
|
+
def get
|
29
|
+
post 'friends.get'
|
30
|
+
end
|
31
|
+
|
32
|
+
# 获取两个用户的共同好友
|
33
|
+
#
|
34
|
+
# @param [int] uid1 用户1
|
35
|
+
# @param [int] uid2 用户2
|
36
|
+
# @param [Hash] opts
|
37
|
+
# @option opts [String] :fields 好友属性列表(逗号分隔)。支持的值有:uid,name,sex,tinyurl,headurl,mainurl。 缺省:uid
|
38
|
+
#
|
39
|
+
# @see http://wiki.dev.renren.com/wiki/Friends.getSameFriends
|
40
|
+
def get_same_friends(uid1, uid2, opts={})
|
41
|
+
post 'friends.getSameFriends', :body => {:uid1 => uid1, :uid2 => uid2}.merge(opts)
|
42
|
+
end
|
43
|
+
|
44
|
+
# 得到当前登录用户的好友列表
|
45
|
+
#
|
46
|
+
# @param [Hash] opts
|
47
|
+
# @option opts [int] :page 分页,默认为1
|
48
|
+
# @option opts [int] :count 返回每页个数,默认为500
|
49
|
+
# @option opts [String] :fields 需要返回的字段,多个字段用逗号(,)隔开。目前支持如下字段: headurl_with_logo, tinyurl_with_logo
|
50
|
+
#
|
51
|
+
# @see http://wiki.dev.renren.com/wiki/Friends.getFriends
|
52
|
+
def get_friends(opts={})
|
53
|
+
post 'friends.getFriends', :body => opts
|
54
|
+
end
|
55
|
+
|
56
|
+
# 返回已经添加了一个应用的好友的用户Id列表,此接口只返回全部好友中的数据
|
57
|
+
#
|
58
|
+
# @see http://wiki.dev.renren.com/wiki/Friends.getAppUsers
|
59
|
+
def get_app_users
|
60
|
+
post 'friends.getAppUsers'
|
61
|
+
end
|
62
|
+
|
63
|
+
# 返回App好友的ID列表
|
64
|
+
#
|
65
|
+
# @param [Hash] opts
|
66
|
+
# @option opts [String] :fields 返回的字段列表,可以指定返回那些字段,用逗号分隔。
|
67
|
+
# 目前支持name(姓名)、tinyurl(小头像)、headurl(中等头像),如果不传递此参数,默认返回好友id节点
|
68
|
+
#
|
69
|
+
# @see http://wiki.dev.renren.com/wiki/Friends.getAppFriends
|
70
|
+
def get_app_friends(opts={})
|
71
|
+
post 'friends.getAppFriends', :body => opts
|
72
|
+
end
|
73
|
+
|
74
|
+
# 搜索用户,根据搜索条件返回搜索结果
|
75
|
+
#
|
76
|
+
# @param [String] name 搜索姓名
|
77
|
+
# @param [Hash] opts
|
78
|
+
# @option opts [String] :condition 查询条件。
|
79
|
+
# json格式如:[{"t":"base","gend":"男生","prov":"天津"},{"t":"high","year":"2000"},{"t":"univ","name":"东北大学"}]
|
80
|
+
# "t"搜索条件类型,各个类型包含的条件如下:
|
81
|
+
# 1. "t":"base" 基本信息,"gend" 性别,"prov" 省份,"city" 城市
|
82
|
+
# 2. "t":"univ" 大学, "name" 大学名称,"id" 大学的id见主站,"depa" 学院,"year" 入学年份
|
83
|
+
# 3. "t":"high" 高中, "name" 高中名称,"year" 入学年份
|
84
|
+
# 4. "t":"sect" 中专技校,"name" 名称, "year" 入学年份
|
85
|
+
# 5. "t":"juni" 初中, "name" 初中名称,"year" 入学年份
|
86
|
+
# 6. "t":"elem" 小学, "name" 小学称, "year" 入学年份
|
87
|
+
# 7. "t":"birt" 生日, "year" 年, "month" 月, "day" 日, "astr" 星座
|
88
|
+
# 8. "t":"work" 公司, "name" 公司名称
|
89
|
+
# @option opts [int] :page 分页显示的页码 缺省值为1
|
90
|
+
# @option opts [int] :count 每页显示的日志的数量, 缺省值为20
|
91
|
+
#
|
92
|
+
# @see http://wiki.dev.renren.com/wiki/Friends.search
|
93
|
+
def search(name, opts={})
|
94
|
+
post 'friends.search', :body => {:name => name}.merge(opts)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# test passed: 2011-11-06 15:39:14
|
3
|
+
module Renren2
|
4
|
+
module Interface
|
5
|
+
|
6
|
+
# Invitations Interface
|
7
|
+
#
|
8
|
+
# @see http://wiki.dev.renren.com/wiki/API
|
9
|
+
class Invitations < Base
|
10
|
+
|
11
|
+
# 生成用户站外邀请用户注册的链接地址,应用可以引导用户通过QQ或者msn等渠道邀请好友加入应用
|
12
|
+
#
|
13
|
+
# @param [Hash] opts
|
14
|
+
# @option opts [int] :domain 获取邀请链接地址的域名属性,0表示人人(wwv.renren.com),1表示开心(wwv.kaixin.com),默认值为人人
|
15
|
+
#
|
16
|
+
# @see http://wiki.dev.renren.com/wiki/Invitations.createLink
|
17
|
+
def create_link(opts={})
|
18
|
+
post 'invitations.createLink', :body => opts
|
19
|
+
end
|
20
|
+
|
21
|
+
# 根据应用新用户的id获取用户是否通过邀请安装,同时得到此次邀请的详细信息(包括邀请者、邀请时间、被邀请者等)
|
22
|
+
#
|
23
|
+
# @param [Hash] opts
|
24
|
+
# @option opts [String] :invitee_id 被邀请者的用户ID
|
25
|
+
# @option opts [String] :inviter_id 邀请者的ID
|
26
|
+
# @option opts [String] :begin_time 查询起始时间,格式为:yyyy-MM-dd HH:mm:ss
|
27
|
+
# @option opts [String] :end_time 查询结束时间,格式为:yyyy-MM-dd HH:mm:ss
|
28
|
+
# @option opts [int] :page 分页的页数,默认值为1
|
29
|
+
# @option opts [int] :count 分页后每页的数量,默认值为100
|
30
|
+
# @note 1.如果想获得某个用户被谁邀请进来的,请传入invitee_id
|
31
|
+
# 2.如果想获得一段时间内所有用户的邀请信息,请传入begin_time和end_time,此时请不要传入invitee_id
|
32
|
+
#
|
33
|
+
# @see http://wiki.dev.renren.com/wiki/Invitations.getInfo
|
34
|
+
def get_info(opts={})
|
35
|
+
post 'invitations.getInfo', :body => opts
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Renren2
|
3
|
+
module Interface
|
4
|
+
|
5
|
+
# Like Interface
|
6
|
+
#
|
7
|
+
# @see http://wiki.dev.renren.com/wiki/API
|
8
|
+
class Like < Base
|
9
|
+
|
10
|
+
# 判断用户是否喜欢过url
|
11
|
+
#
|
12
|
+
# @param [String] uids uid列表的JSON,上限100,结构如下所示:[8055,8066,8077]
|
13
|
+
# @param [String] urls url列表的JSON,上限100,结构如下所示:[“http://www.docin.com/p-1141554.html”, “http://www.docin.com/p-35584072.html”]
|
14
|
+
#
|
15
|
+
# @see http://wiki.dev.renren.com/wiki/Like.isLiked
|
16
|
+
def is_liked(uids, urls)
|
17
|
+
post 'like.isLiked', :body => {:uids => uids, :urls => urls}
|
18
|
+
end
|
19
|
+
|
20
|
+
# 获取url被喜欢的次数
|
21
|
+
#
|
22
|
+
# @param [String] urls url列表的JSON,上限100,结构如下所示:[“http://www.docin.com/p-1141554.html”, “http://www.docin.com/p-35584072.html”]
|
23
|
+
#
|
24
|
+
# @see http://wiki.dev.renren.com/wiki/Like.getCount
|
25
|
+
def get_count(urls)
|
26
|
+
post 'like.getCount', :body => {:urls => urls}
|
27
|
+
end
|
28
|
+
|
29
|
+
# no test below
|
30
|
+
# 对某一url执行喜欢操作
|
31
|
+
#
|
32
|
+
# @param [String] url 被喜欢的url
|
33
|
+
# @note require "operate_like" scope
|
34
|
+
#
|
35
|
+
# @see http://wiki.dev.renren.com/wiki/Like.like
|
36
|
+
def like(url)
|
37
|
+
check_scope "operate_like"
|
38
|
+
post 'like.like', :body => {:url => url}
|
39
|
+
end
|
40
|
+
|
41
|
+
# 对某一url执行取消喜欢操作
|
42
|
+
#
|
43
|
+
# @param [String] url 被取消喜欢的url
|
44
|
+
# @note require "operate_like" scope
|
45
|
+
#
|
46
|
+
# @see http://wiki.dev.renren.com/wiki/Like.unlike
|
47
|
+
def unlike(url)
|
48
|
+
check_scope "operate_like"
|
49
|
+
post 'like.unlike', :body => {:url => url}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Renren2
|
3
|
+
module Interface
|
4
|
+
|
5
|
+
# Notifications Interface
|
6
|
+
#
|
7
|
+
# @see http://wiki.dev.renren.com/wiki/API
|
8
|
+
class Notifications < Base
|
9
|
+
|
10
|
+
# test failed: to_ids set to nil, failed..
|
11
|
+
# 给当前登录者的好友或也安装了同样应用的用户发通知
|
12
|
+
#
|
13
|
+
# @param [String] to_ids 用户id的列表,单个或多个,可以是逗号分隔,如 8055,8066,8077。这些用户必须是当前登录者的好友或也安装了此应用。
|
14
|
+
# 请确保一次传入的用户id数少于20个。如果要给当前用户发送通知,请指定此参数值为空串。
|
15
|
+
# @param [String] notification 通知的内容,可以是XNML类型的文本信息,支持的XNML有<xn:name/>和<a/>,
|
16
|
+
# 请注意:使用<xn:name/>标签的时候,其uid属性值只能是真实的用户id(阿拉伯数字)。
|
17
|
+
#
|
18
|
+
# @see http://wiki.dev.renren.com/wiki/Notifications.send
|
19
|
+
def send(to_ids, notification)
|
20
|
+
post 'notifications.send', :body => {:to_ids => to_ids, :notification => notification}
|
21
|
+
end
|
22
|
+
|
23
|
+
# no test
|
24
|
+
# 给你的用户发送Email
|
25
|
+
#
|
26
|
+
# @param [int] template_id 邮件模板的ID
|
27
|
+
# @param [String] recipients 收件人的UID,多个ID用逗号隔开,例如:2838234,2342312. 一次最多100个ID
|
28
|
+
# @param [String] template_data JSON对象,渲染邮件模板所需要的数据。例如:{"who":"234234","static_uid":"23423423"}
|
29
|
+
# @param [Hash] opts
|
30
|
+
# @option opts [int] :uid 用户的ID
|
31
|
+
# @note require "email" scope
|
32
|
+
#
|
33
|
+
# @see http://wiki.dev.renren.com/wiki/Notifications.sendEmail
|
34
|
+
# @see http://wiki.dev.renren.com/wiki/HowToSendEmail
|
35
|
+
def send_email(template_id, recipients, template_data, opts={})
|
36
|
+
check_scope "email"
|
37
|
+
post 'notifications.sendEmail', :body => {:template_id => template_id,
|
38
|
+
:recipients => recipients,
|
39
|
+
:template_data => template_data}.merge(opts)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# test passed: 2011-11-07 21:23:56
|
3
|
+
module Renren2
|
4
|
+
module Interface
|
5
|
+
|
6
|
+
# Pages Interface
|
7
|
+
#
|
8
|
+
# @see http://wiki.dev.renren.com/wiki/API
|
9
|
+
class Pages < Base
|
10
|
+
|
11
|
+
# 获取当前用户管理的Page列表
|
12
|
+
#
|
13
|
+
# @param [Hash] opts
|
14
|
+
# @option opts [int] :page 页码,默认值为1
|
15
|
+
# @option opts [int] :count 每页的容量,默认值为10
|
16
|
+
#
|
17
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.getManagedList
|
18
|
+
def get_managed_list(opts={})
|
19
|
+
post 'pages.getManagedList', :body => opts
|
20
|
+
end
|
21
|
+
|
22
|
+
# 成为某个Page的粉丝
|
23
|
+
#
|
24
|
+
# @param [int] page_id Page的ID
|
25
|
+
#
|
26
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.becomeFan
|
27
|
+
def become_fan(page_id)
|
28
|
+
post 'pages.becomeFan', :body => {:page_id => page_id}
|
29
|
+
end
|
30
|
+
|
31
|
+
# 与某个公共主页解除粉丝关系
|
32
|
+
#
|
33
|
+
# @param [int] page_id Page的ID
|
34
|
+
#
|
35
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.quit
|
36
|
+
def quit(page_id)
|
37
|
+
post 'pages.quit', :body => {:page_id => page_id}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Page管理员修改Page的状态
|
41
|
+
#
|
42
|
+
# @param [String] status 管理员更新的page状态信息,最多140个字符
|
43
|
+
# @param [int] page_id Page的ID
|
44
|
+
#
|
45
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.setStatus
|
46
|
+
def set_status(status, page_id)
|
47
|
+
post 'pages.setStatus', :body => {:status => status, :page_id => page_id}
|
48
|
+
end
|
49
|
+
|
50
|
+
# 判断用户是否为Page的粉丝
|
51
|
+
#
|
52
|
+
# @param [Hash] opts
|
53
|
+
# @option opts [int] :uid 用户的ID
|
54
|
+
# @option opts [int] :page_id Page的ID,缺省时,值为当前应用对应的Page的ID
|
55
|
+
#
|
56
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.isFan
|
57
|
+
def is_fan(opts={})
|
58
|
+
post 'pages.isFan', :body => opts
|
59
|
+
end
|
60
|
+
|
61
|
+
# 获取公共主页的类型
|
62
|
+
#
|
63
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.getCategories
|
64
|
+
def get_categories
|
65
|
+
post 'pages.getCategories'
|
66
|
+
end
|
67
|
+
|
68
|
+
# 获取某个Page的信息
|
69
|
+
#
|
70
|
+
# @param [int] page_id Page的ID
|
71
|
+
# @param [String] fields 需要返回的字段的列表,多个字段间用逗号隔开。现在支持:status(当前状态),desc(描述),
|
72
|
+
# base_info(基本信息),albums_count(相册总数),blogs_count(日志总数), fans_count(粉丝总数),
|
73
|
+
# detail_info(详细信息), contact_info(联系信息)
|
74
|
+
#
|
75
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.getInfo
|
76
|
+
def get_info(page_id, fields)
|
77
|
+
post 'pages.getInfo', :body => {:page_id => page_id, :fields => fields}
|
78
|
+
end
|
79
|
+
|
80
|
+
# 判断当前用户是否是某个Page的管理员
|
81
|
+
#
|
82
|
+
# @param [int] page_id Page的ID
|
83
|
+
#
|
84
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.isAdmin
|
85
|
+
def is_admin(page_id)
|
86
|
+
post 'pages.isAdmin', :body => {:page_id => page_id}
|
87
|
+
end
|
88
|
+
|
89
|
+
# 判断一个ID是否为Page
|
90
|
+
#
|
91
|
+
# @param [int] page_id Page的ID
|
92
|
+
#
|
93
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.isPage
|
94
|
+
def is_page(page_id)
|
95
|
+
post 'pages.isPage', :body => {:page_id => page_id}
|
96
|
+
end
|
97
|
+
|
98
|
+
# 获取Page的列表
|
99
|
+
#
|
100
|
+
# @param [Hash] opts
|
101
|
+
# @option opts [int] :uid 用户的ID。当此参数不为空时表示获取此人关注的公共主页列表
|
102
|
+
# @option opts [int] :page 页码,默认值为1
|
103
|
+
# @option opts [int] :count 每页的容量,默认值为10
|
104
|
+
# @option opts [int] :category 分类的ID。缺省时表示获取所有类型的公共主页
|
105
|
+
#
|
106
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.getList
|
107
|
+
def get_list(opts={})
|
108
|
+
post 'pages.getList', :body => opts
|
109
|
+
end
|
110
|
+
|
111
|
+
# 获取Page粉丝的列表
|
112
|
+
#
|
113
|
+
# @param [int] page_id Page的ID
|
114
|
+
# @param [Hash] opts
|
115
|
+
# @option opts [int] :page 分页显示的页码 缺省值为1
|
116
|
+
# @option opts [int] :count 每页显示的粉丝的数量, 缺省值为10
|
117
|
+
#
|
118
|
+
# @see http://wiki.dev.renren.com/wiki/Pages.getFansList
|
119
|
+
def get_fans_list(page_id, opts={})
|
120
|
+
post 'pages.getFansList', :body => {:page_id => page_id}.merge(opts)
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|