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.
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+ module Renren2
3
+ module Interface
4
+
5
+ # Pay Interface
6
+ #
7
+ # @see http://wiki.dev.renren.com/wiki/API
8
+ class Pay < Base
9
+
10
+ # 查询某个用户在一个应用中一次消费是否完成
11
+ #
12
+ # @param [int64] order_id 用户消费校内豆订单号
13
+ #
14
+ # @see http://wiki.dev.renren.com/wiki/Pay.isCompleted
15
+ def is_completed(order_id)
16
+ post 'pay.isCompleted', :body => {:order_id => order_id}
17
+ end
18
+
19
+ # 预存入用户在应用中消费产生的订单数据,消费数额等信息
20
+ #
21
+ # @param [int64] order_id 用户消费校内豆订单号,参数必须保证唯一,每一次不能传递相同的参数
22
+ # @option opts [int] :amount 校内豆消费数额, 取值范围为[0,1000]
23
+ # @option opts [String] :desc 用户使用校内豆购买的虚拟物品的名称
24
+ # @param [Hash] opts
25
+ # @option opts [int] :type 0代表WEB支付订单,1代表WAP支付订单,默认值为0
26
+ #
27
+ # @see http://wiki.dev.renren.com/wiki/Pay.regOrder
28
+ def reg_order(order_id, amount, desc, opts={})
29
+ post 'pay.regOrder', :body => {:order_id => order_id, :amount => amount, :desc => desc}.merge(opts)
30
+ end
31
+
32
+ # 根据订单号查询订单,支持批量查询
33
+ #
34
+ # @param [String] order_numbers 订单号,多个订单用逗号隔开
35
+ #
36
+ # @see http://wiki.dev.renren.com/wiki/Pay.queryOrders
37
+ def query_orders(order_numbers)
38
+ post 'pay.queryOrders', :body => {:order_numbers => order_numbers}
39
+ end
40
+
41
+ # 查询某个用户在一个应用中一次消费是否完成
42
+ #
43
+ # @param [int64] order_id 用户消费校内豆订单号
44
+ #
45
+ # @see http://wiki.dev.renren.com/wiki/Pay4Test.isCompleted
46
+ def test_is_completed(order_id)
47
+ post 'pay4Test.isCompleted', :body => {:order_id => order_id}
48
+ end
49
+
50
+ # 预存入用户在应用中消费产生的订单数据,消费数额等信息
51
+ #
52
+ # @param [int64] order_id 用户消费校内豆订单号,参数必须保证唯一,每一次不能传递相同的参数
53
+ # @option opts [int] :amount 校内豆消费数额, 取值范围为[0,1000]
54
+ # @option opts [String] :desc 用户使用校内豆购买的虚拟物品的名称
55
+ # @param [Hash] opts
56
+ # @option opts [int] :type 0代表WEB支付订单,1代表WAP支付订单,默认值为0
57
+ #
58
+ # @see http://wiki.dev.renren.com/wiki/Pay4Test.regOrder
59
+ def test_reg_order(order_id, amount, desc, opts={})
60
+ post 'pay4Test.regOrder', :body => {:order_id => order_id, :amount => amount, :desc => desc}.merge(opts)
61
+ end
62
+
63
+ end
64
+ end
65
+ end
66
+
@@ -0,0 +1,178 @@
1
+ module Renren2
2
+ module Interface
3
+
4
+ # Photos Interface
5
+ #
6
+ # @see http://wiki.dev.renren.com/wiki/API
7
+ class Photos < Base
8
+
9
+ # 以人人用户的身份创建相册
10
+ #
11
+ # @param [String] name 相册的名字
12
+ # @param [Hash] opts
13
+ # @option opts [String] :location 相册的地点
14
+ # @option opts [String] :description 相册的描述
15
+ # @option opts [String] :visible 相册的隐私设置. owner(自己)、friends(好友)、 networks(网络)、everyone(所有人)。
16
+ # 99(所有人),1(好友), 3(同网络人), -1(仅自己可见)
17
+ # @option opts [String] :password 相册的密码,支持字母,数字,符号,限16个字符
18
+ # @note require "create_album" scope
19
+ #
20
+ # @see http://wiki.dev.renren.com/wiki/Photos.createAlbum
21
+ def create_album(name, opts={})
22
+ check_scope "create_album"
23
+ post 'photos.createAlbum', :body => {:name => name}.merge(opts)
24
+ end
25
+
26
+ # 获取用户的相册列表信息。当取第一页时,会返回头像相册和快速上传相册
27
+ #
28
+ # @param [int] uid 相册所有者的用户ID
29
+ # @param [Hash] opts
30
+ # @option opts [int] :page 分页的页数,默认值为1
31
+ # @option opts [int] :count 分页后每页的个数,默认值为10
32
+ # @option opts [String] :aids 多个相册的ID,以逗号分隔,最多支持10个数据
33
+ # @note require "read_user_album" scope
34
+ #
35
+ # @see http://wiki.dev.renren.com/wiki/Photos.getAlbums
36
+ def get_albums(uid, opts={})
37
+ check_scope "read_user_album"
38
+ post 'photos.getAlbums', :body => {:uid => uid}.merge(opts)
39
+ end
40
+
41
+ # 上传照片到用户的相册,同时返回这张照片的信息
42
+ #
43
+ # @param [binary] upload 文件的数据
44
+ # @param [Hash] opts
45
+ # @option opts [String] :caption 照片的描述信息
46
+ # @option opts [int] :aid 相册的ID,如果指定此参数,将会传到指定相册,默认传到手机相册
47
+ # @option opts [String] :place_id 上传照片所在地点的ID
48
+ # @note require "photo_upload" scope
49
+ #
50
+ # @see http://wiki.dev.renren.com/wiki/Photos.upload
51
+ def upload(upload, opts={})
52
+ check_scope "photo_upload"
53
+ post 'photos.upload', :body => {:upload => upload}.merge(opts)
54
+ end
55
+
56
+ # 获取可见照片的相关信息
57
+ #
58
+ # @param [int] uid 照片所有者的用户ID或公共主页的ID
59
+ # @param [Hash] opts
60
+ # @option opts [int64] :aid 相册的id。aid和pids至少传递一个
61
+ # @option opts [String] :password 加密相册的密码
62
+ # @option opts [int] :page 页码,默认值为1
63
+ # @option opts [int] :count 每页的容量,默认值为10,必须大于0,小于200
64
+ # @option opts [String] :pids 照片id串,以分","割,最多20个
65
+ # @note require "read_user_photo" scope
66
+ #
67
+ # @see http://wiki.dev.renren.com/wiki/Photos.get
68
+ def get(uid, opts={})
69
+ check_scope "read_user_photo"
70
+ post 'photos.get', :body => {:uid => uid}.merge(opts)
71
+ end
72
+
73
+ # 对可见照片或者相册进行评论
74
+ #
75
+ # @param [int] uid 照片或相册所有者的用户ID
76
+ # @param [String] content 评论的内容,最多140字
77
+ # @param [Hash] opts
78
+ # @option opts [int64] :aid 相册的id。aid和pid至少传递一个
79
+ # @option opts [String] :pid 照片id。aid和pid至少传递一个
80
+ # @option opts [int64] :rid 评论的用户id,如果想对评论中的评论进行二级回复需要传递此参数
81
+ # @option opts [int] :type 评论的类型,是否为悄悄话,1表示悄悄话,0表示非悄悄话,默认为0
82
+ # @note require "read_user_photo,publish_comment" scope
83
+ #
84
+ # @see http://wiki.dev.renren.com/wiki/Photos.addComment
85
+ def add_comment(uid, content, opts={})
86
+ check_scope "read_user_photo"
87
+ check_scope "publish_comment"
88
+ post 'photos.addComment', :body => {:uid => uid, :content => content}.merge(opts)
89
+ end
90
+
91
+ # 获取可见照片的相关评论内容
92
+ #
93
+ # @param [int] uid 照片或相册所有者的用户ID
94
+ # @param [Hash] opts
95
+ # @option opts [int64] :aid 相册的id。aid和pid至少传递一个
96
+ # @option opts [String] :pid 照片id。aid和pid至少传递一个
97
+ # @option opts [int] :page 支持分页,缺省值为1(第一页)
98
+ # @option opts [int] :count 每页的数量,缺省值为10
99
+ # @note require "read_user_photo,read_user_comment" scope
100
+ #
101
+ # @see http://wiki.dev.renren.com/wiki/Photos.getComments
102
+ def get_comments(uid, opts={})
103
+ check_scope "read_user_photo"
104
+ check_scope "read_user_comment"
105
+ post 'photos.getComments', :body => {:uid => uid}.merge(opts)
106
+ end
107
+
108
+ # 圈出照片中的好友或人
109
+ #
110
+ # @param [int] photo_id 照片的ID
111
+ # @param [int] owner_id 照片所有者的ID
112
+ # @param [int] photo_width 照片的宽度,以像素为单位。由于photos.get没有下发照片的宽和高,需要开发者自行计算图片的宽和高
113
+ # @param [int] photo_height 照片的高度,以像素为单位
114
+ # @param [int] top 圈人框距照片上端的距离,以像素为单位
115
+ # @param [int] left 圈人框距照片左端的距离,以像素为单位
116
+ # @param [int] frame_width 圈人框的宽度,以像素为单位
117
+ # @param [int] frame_height 圈人框的高度,以像素为单位
118
+ # @param [Hash] opts
119
+ # @option opts [int] :tagged_user_id 被圈用户的ID,该ID对应用户必须与session_key对应用户为好友关系
120
+ # @option opts [String] :tagged_user_name 被圈用户的名字,若被圈的人没有人人用户ID时,可以传递user_name参数
121
+ # @note require "send_request" scope
122
+ #
123
+ # @see http://wiki.dev.renren.com/wiki/Photos.tag
124
+ def tag(photo_id, owner_id, photo_width, photo_height, top, left, frame_width, frame_height, opts={})
125
+ check_scope "send_request"
126
+ post 'photos.tag', :body => {:photo_id => photo_id,
127
+ :owner_id => owner_id,
128
+ :photo_width => photo_width,
129
+ :photo_height => photo_height,
130
+ :top => top,
131
+ :left => left,
132
+ :frame_width => frame_width,
133
+ :frame_height => frame_height}.merge(opts)
134
+ end
135
+
136
+ # 获取照片中圈出的好友或人
137
+ #
138
+ # @param [int] photo_id 照片的ID
139
+ # @param [int] owner_id 照片所有者的ID
140
+ # @param [Hash] opts
141
+ # @option opts [int] :page 页码。默认值为1
142
+ # @option opts [int] :count 每页个数。默认为100,必须大于0,小于200
143
+ # @note require "read_user_photo" scope
144
+ #
145
+ # @see http://wiki.dev.renren.com/wiki/Photos.getTags
146
+ def get_tags(photo_id, owner_id, opts={})
147
+ check_scope "read_user_photo"
148
+ post 'photos.getTags', :body => {:photo_id => photo_id, :owner_id => owner_id}.merge(opts)
149
+ end
150
+
151
+ # 接受圈人请求
152
+ #
153
+ # @param [int] tag_id 圈人(Tag)的ID
154
+ # @param [int] photo_owner_id 圈人(Tag)所在照片所有者的ID
155
+ # @note require "deal_request" scope
156
+ #
157
+ # @see http://wiki.dev.renren.com/wiki/Photos.acceptTag
158
+ def accept_tag(tag_id, photo_owner_id)
159
+ check_scope "deal_request"
160
+ post 'photos.acceptTag', :body => {:tag_id => tag_id, :photo_owner_id => photo_owner_id}
161
+ end
162
+
163
+ # 拒绝接受圈人请求
164
+ #
165
+ # @param [int] tag_id 圈人(Tag)的ID
166
+ # @param [int] photo_owner_id 圈人(Tag)所在照片所有者的ID
167
+ # @note require "deal_request" scope
168
+ #
169
+ # @see http://wiki.dev.renren.com/wiki/Photos.refuseTag
170
+ def refuse_tag(tag_id, photo_owner_id)
171
+ check_scope "deal_request"
172
+ post 'photos.refuseTag', :body => {:tag_id => tag_id, :photo_owner_id => photo_owner_id}
173
+ end
174
+
175
+ end
176
+ end
177
+ end
178
+
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ # test passed: 2011-11-06 16:51:21
3
+ module Renren2
4
+ module Interface
5
+
6
+ # Places Interface
7
+ #
8
+ # @see http://wiki.dev.renren.com/wiki/API
9
+ class Places < Base
10
+
11
+ # 允许用户添加一个地点
12
+ #
13
+ # @param [String] poi_id 用户任意传递的字符串,要求可以唯一标示一个POI(Point Of Interest),用于服务端去重,
14
+ # 如果传递之前传递过的poi_id,将不会创建地点,而是将上次用该poi_id创建的地点信息进行替换,
15
+ # 并返回上次创建地点的place_id
16
+ # @param [String] name 地点的名称
17
+ # @param [String] address 地点的地址
18
+ # @param [String] longitude 地点的经度,有效范围-180.0到+180.0,“+”表示东经
19
+ # @param [String] latitude 地点的纬度,有效范围-90.0到+90.0,“+”表示北纬
20
+ # @param [Hash] opts
21
+ # @option opts [String] :zip 地点的邮政编码
22
+ # @option opts [String] :phone 地点的联系电话,若有多个,以“,”(半角)分隔
23
+ # @option opts [String] :country 地点所在的国家
24
+ # @option opts [String] :province 地点所在的省份
25
+ # @option opts [String] :city 地点所在的城市
26
+ # @option opts [String] :district 地点所在的区
27
+ # @option opts [String] :crossstreet 地点所在的街道或交叉路口,若是交叉路口,以“&”分隔
28
+ #
29
+ # @see http://http://wiki.dev.renren.com/wiki/Places.create
30
+ def create(poi_id, name, address, longitude, latitude, opts={})
31
+ post 'places.create', :body => {:poi_id => poi_id,
32
+ :name => name,
33
+ :address => address,
34
+ :longitude => longitude,
35
+ :latitude => latitude}.merge(opts)
36
+ end
37
+ end
38
+ end
39
+ end
40
+
@@ -0,0 +1,25 @@
1
+ module Renren2
2
+ module Interface
3
+
4
+ # Requests Interface
5
+ #
6
+ # @see http://wiki.dev.renren.com/wiki/API
7
+ class Requests < Base
8
+
9
+ # 获取当前用户的圈人请求列表,在调用之前,应用必须获取到用户的授权
10
+ #
11
+ # @param [Hash] opts
12
+ # @option opts [int] :page 支持分页,指定页号,页号从1开始,默认值为1
13
+ # @option opts [int] :count 支持分页,每一页记录数,默认值为20
14
+ # @note require "read_user_request" scope
15
+ #
16
+ # @see http://http://wiki.dev.renren.com/wiki/Requests.getTagRequests
17
+ def get_tag_requests(opts={})
18
+ check_scope "read_user_request"
19
+ post 'requests.getTagRequests', :body => opts
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+ module Renren2
3
+ module Interface
4
+
5
+ # Share Interface
6
+ #
7
+ # @see http://wiki.dev.renren.com/wiki/API
8
+ class Share < Base
9
+
10
+ # 发布分享,例如分享视频、音乐、链接、日志、相册、照片等
11
+ #
12
+ # @param [int] type 分享的类型:日志为1、照片为2、链接为6、相册为8、视频为10、音频为11、分享为20
13
+ # @param [Hash] opts
14
+ # @option opts [int] :ugc_id 分享人人网站内内容的ID。如日志、照片、相册、分享的ID
15
+ # @option opts [int] :user_id 分享人人网站内内容所有者的ID。如日志、照片、相册、分享所有者的用户ID
16
+ # @option opts [String] :url 分享人人网站外内容的URL
17
+ # @option opts [String] :comment 分享内容时,用户的评论内容
18
+ # @note require "publish_share" scope
19
+ #
20
+ # @see http://wiki.dev.renren.com/wiki/Share.share
21
+ def share(type, opts={})
22
+ check_scope "publish_share"
23
+ post 'share.share', :body => {:type => type}.merge(opts)
24
+ end
25
+
26
+ # 获取某个分享的评论
27
+ #
28
+ # @param [int] user_id 分享所有者的ID
29
+ # @param [int] share_id 所要取得评论的分享的ID
30
+ # @note require "read_user_share、read_user_comment" scope
31
+ #
32
+ # @see http://wiki.dev.renren.com/wiki/Share.getComments
33
+ def get_comments(user_id, share_id)
34
+ check_scope "read_user_share"
35
+ check_scope "read_user_comment"
36
+ post 'share.getComments', :body => {:user_id => user_id, :share_id => share_id}
37
+ end
38
+
39
+ # 对某个分享进行评论
40
+ #
41
+ # @param [int] share_id 被回复分享的ID
42
+ # @param [int] user_id 被回复分享所有者的用户ID
43
+ # @param [String] content 回复的内容
44
+ # @param [Hash] opts
45
+ # @option opts [int] :to_user_id 被回复用户的ID
46
+ # @note require "publish_comment、publish_share" scope
47
+ #
48
+ # @see http://wiki.dev.renren.com/wiki/Share.addComment
49
+ def add_comment(share_id, user_id, content, opts={})
50
+ check_scope "publish_comment"
51
+ check_scope "publish_share"
52
+ post 'share.addComment', :body => {:share_id => share_id, :user_id => user_id, :content => content}.merge(opts)
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+
@@ -0,0 +1,108 @@
1
+ module Renren2
2
+ module Interface
3
+
4
+ # Status API
5
+ #
6
+ # @see http://wiki.dev.renren.com/wiki/API
7
+ class Status < Base
8
+
9
+ # 返回指定用户的状态列表,不包含回复内容。如果不指定用户,则获取当前用户的状态信息
10
+ #
11
+ # @param [Hash] opts
12
+ # @option opts [int] :uid 状态信息所属用户id,不指定则判断为当前用户
13
+ # @option opts [int] :page 支持分页,指定页号,页号从1开始。缺省返回第一页数据
14
+ # @option opts [int] :count 支持分页,指定每页记录数,缺省为每页10条记录。最大不能超过1000
15
+ # @note require "read_user_status" scope
16
+ #
17
+ # @see http://wiki.dev.renren.com/wiki/Status.gets
18
+ def gets(opts={})
19
+ check_scope "read_user_status"
20
+ post 'status.gets', :body => opts
21
+ end
22
+
23
+ # 用户更新状态
24
+ #
25
+ # @param [String] status 用户更新的状态信息,最多140个字符
26
+ # @param [Hash] opts
27
+ # @option opts [String] :place_id 发状态时所在地点的ID
28
+ # @note require "status_update" scope
29
+ #
30
+ # @see http://wiki.dev.renren.com/wiki/Status.set
31
+ def set(status, opts={})
32
+ check_scope "status_update"
33
+ post 'status.set', :body => {:status => status}.merge(opts)
34
+ end
35
+
36
+ # 返回用户某条状态,不包含回复内容
37
+ #
38
+ # @param [int64] status_id 状态的id,如果未指定状态id则返回当前用户最新的状态
39
+ # @param [Hash] opts
40
+ # @option opts [int64] :owner_id 状态信息所属用户id,不指定则为当前用户
41
+ # @note require "read_user_status" scope
42
+ #
43
+ # @see http://wiki.dev.renren.com/wiki/Status.get
44
+ def get(status_id, opts={})
45
+ check_scope "read_user_status"
46
+ post 'status.get', :body => {:status_id => status_id}.merge(opts)
47
+ end
48
+
49
+ # 获取一条状态中的所有最新回复内容
50
+ #
51
+ # @param [int64] status_id 状态的id
52
+ # @param [int] owner_id 状态所有者的id
53
+ # @param [Hash] opts
54
+ # @option opts [int] :page 支持分页,指定页号,页号从1开始。缺省返回第一页数据
55
+ # @option opts [int] :count 支持分页,指定每页记录数,缺省为每页10条记录
56
+ # @option opts [int] :order 获取留言的排序规则,0表示升序(最旧到新),1表示降序(最新到旧),默认为0
57
+ # @note require "read_user_status" scope
58
+ #
59
+ # @see http://wiki.dev.renren.com/wiki/Status.getComment
60
+ def get_comment(status_id, owner_id, opts={})
61
+ check_scope "read_user_status"
62
+ post 'status.getComment', :body => {:status_id => status_id, :owner_id => owner_id}.merge(opts)
63
+ end
64
+
65
+ # no test
66
+ # 对一条状态增加一条回复
67
+ #
68
+ # @param [int] owner_id 状态所有者的id
69
+ # @param [String] content 回复的内容
70
+ # @param [int64] status_id 状态的id
71
+ # @param [Hash] opts
72
+ # @option opts [int64] :rid 被回复的用户的ID,如果是直接回复某条状态,此参数不用传
73
+ # @note require "read_user_status,publish_comment" scope
74
+ #
75
+ # @see http://wiki.dev.renren.com/wiki/Status.addComment
76
+ def add_comment(owner_id, content, status_id, opts={})
77
+ check_scope "read_user_status"
78
+ check_scope "publish_comment"
79
+ post 'status.addComment', :body => {:owner_id => owner_id, :content => content, :status_id => status_id}.merge(opts)
80
+ end
81
+
82
+ # 获取状态中的表情图片和表情符号对应列表
83
+ #
84
+ # @param [Hash] opts
85
+ # @option opts [String] :type 获取列表的类型,type为all返回全部数据,type为recent返回网页同步数据,默认网页同步数据
86
+ #
87
+ # @see http://wiki.dev.renren.com/wiki/Status.getEmoticons
88
+ def get_emoticons(opts={})
89
+ post 'status.getEmoticons', :body => opts
90
+ end
91
+
92
+ # 用户转发状态的操作,支持同时评论给转发人
93
+ #
94
+ # @param [String] status 用户更新的状态信息,与转发前的内容加在一起最多140个字符
95
+ # @param [int64] forward_id 被转发的状态id
96
+ # @param [int] forward_owner 被转发的状态所有者的id
97
+ # @note require "status_update" scope
98
+ #
99
+ # @see http://wiki.dev.renren.com/wiki/Status.forward
100
+ def forward(status, forward_id, forward_owner)
101
+ check_scope "status_update"
102
+ post 'status.forward', :body => {:status => status, :forward_id => forward_id, :forward_owner => forward_owner}
103
+ end
104
+
105
+ end
106
+
107
+ end
108
+ end