Class: Renren2::Interface::Photos

Inherits:
Base
  • Object
show all
Defined in:
lib/renren2/interface/photos.rb

Overview

Photos Interface

Instance Method Summary collapse

Methods inherited from Base

#check_scope, #initialize, #post, #request

Constructor Details

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

Instance Method Details

#accept_tag(tag_id, photo_owner_id) ⇒ Object

Note:

require “deal_request” scope

接受圈人请求

Parameters:

  • tag_id (int)

    圈人(Tag)的ID

  • photo_owner_id (int)

    圈人(Tag)所在照片所有者的ID

See Also:



159
160
161
162
# File 'lib/renren2/interface/photos.rb', line 159

def accept_tag(tag_id, photo_owner_id)
  check_scope "deal_request"
  post 'photos.acceptTag', :body => {:tag_id => tag_id, :photo_owner_id => photo_owner_id}
end

#add_comment(uid, content, opts = {}) ⇒ Object

Note:

require “read_user_photo,publish_comment” scope

对可见照片或者相册进行评论

Parameters:

  • uid (int)

    照片或相册所有者的用户ID

  • content (String)

    评论的内容,最多140字

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

Options Hash (opts):

  • :aid (int64)

    相册的id。aid和pid至少传递一个

  • :pid (String)

    照片id。aid和pid至少传递一个

  • :rid (int64)

    评论的用户id,如果想对评论中的评论进行二级回复需要传递此参数

  • :type (int)

    评论的类型,是否为悄悄话,1表示悄悄话,0表示非悄悄话,默认为0

See Also:



86
87
88
89
90
# File 'lib/renren2/interface/photos.rb', line 86

def add_comment(uid, content, opts={})
  check_scope "read_user_photo"
  check_scope "publish_comment"
  post 'photos.addComment', :body => {:uid => uid, :content => content}.merge(opts)
end

#create_album(name, opts = {}) ⇒ Object

Note:

require “create_album” scope

以人人用户的身份创建相册

Parameters:

  • name (String)

    相册的名字

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

Options Hash (opts):

  • :location (String)

    相册的地点

  • :description (String)

    相册的描述

  • :visible (String)

    相册的隐私设置. owner(自己)、friends(好友)、 networks(网络)、everyone(所有人)。 99(所有人),1(好友), 3(同网络人), -1(仅自己可见)

  • :password (String)

    相册的密码,支持字母,数字,符号,限16个字符

See Also:



21
22
23
24
# File 'lib/renren2/interface/photos.rb', line 21

def create_album(name, opts={})
  check_scope "create_album"
  post 'photos.createAlbum', :body => {:name => name}.merge(opts)
end

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

Note:

require “read_user_photo” scope

获取可见照片的相关信息

Parameters:

  • uid (int)

    照片所有者的用户ID或公共主页的ID

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

Options Hash (opts):

  • :aid (int64)

    相册的id。aid和pids至少传递一个

  • :password (String)

    加密相册的密码

  • :page (int)

    页码,默认值为1

  • :count (int)

    每页的容量,默认值为10,必须大于0,小于200

  • :pids (String)

    照片id串,以分“,”割,最多20个

See Also:



69
70
71
72
# File 'lib/renren2/interface/photos.rb', line 69

def get(uid, opts={})
  check_scope "read_user_photo"
  post 'photos.get', :body => {:uid => uid}.merge(opts)
end

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

Note:

require “read_user_album” scope

获取用户的相册列表信息。当取第一页时,会返回头像相册和快速上传相册

Parameters:

  • uid (int)

    相册所有者的用户ID

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

Options Hash (opts):

  • :page (int)

    分页的页数,默认值为1

  • :count (int)

    分页后每页的个数,默认值为10

  • :aids (String)

    多个相册的ID,以逗号分隔,最多支持10个数据

See Also:



36
37
38
39
# File 'lib/renren2/interface/photos.rb', line 36

def get_albums(uid, opts={})
  check_scope "read_user_album"
  post 'photos.getAlbums', :body => {:uid => uid}.merge(opts)
end

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

Note:

require “read_user_photo,read_user_comment” scope

获取可见照片的相关评论内容

Parameters:

  • uid (int)

    照片或相册所有者的用户ID

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

Options Hash (opts):

  • :aid (int64)

    相册的id。aid和pid至少传递一个

  • :pid (String)

    照片id。aid和pid至少传递一个

  • :page (int)

    支持分页,缺省值为1(第一页)

  • :count (int)

    每页的数量,缺省值为10

See Also:



103
104
105
106
107
# File 'lib/renren2/interface/photos.rb', line 103

def get_comments(uid, opts={})
  check_scope "read_user_photo"
  check_scope "read_user_comment"
  post 'photos.getComments', :body => {:uid => uid}.merge(opts)
end

#get_tags(photo_id, owner_id, opts = {}) ⇒ Object

Note:

require “read_user_photo” scope

获取照片中圈出的好友或人

Parameters:

  • photo_id (int)

    照片的ID

  • owner_id (int)

    照片所有者的ID

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

Options Hash (opts):

  • :page (int)

    页码。默认值为1

  • :count (int)

    每页个数。默认为100,必须大于0,小于200

See Also:



147
148
149
150
# File 'lib/renren2/interface/photos.rb', line 147

def get_tags(photo_id, owner_id, opts={})
  check_scope "read_user_photo"
  post 'photos.getTags', :body => {:photo_id => photo_id, :owner_id => owner_id}.merge(opts)
end

#refuse_tag(tag_id, photo_owner_id) ⇒ Object

Note:

require “deal_request” scope

拒绝接受圈人请求

Parameters:

  • tag_id (int)

    圈人(Tag)的ID

  • photo_owner_id (int)

    圈人(Tag)所在照片所有者的ID

See Also:



171
172
173
174
# File 'lib/renren2/interface/photos.rb', line 171

def refuse_tag(tag_id, photo_owner_id)
  check_scope "deal_request"
  post 'photos.refuseTag', :body => {:tag_id => tag_id, :photo_owner_id => photo_owner_id}
end

#tag(photo_id, owner_id, photo_width, photo_height, top, left, frame_width, frame_height, opts = {}) ⇒ Object

Note:

require “send_request” scope

圈出照片中的好友或人

Parameters:

  • photo_id (int)

    照片的ID

  • owner_id (int)

    照片所有者的ID

  • photo_width (int)

    照片的宽度,以像素为单位。由于photos.get没有下发照片的宽和高,需要开发者自行计算图片的宽和高

  • photo_height (int)

    照片的高度,以像素为单位

  • top (int)

    圈人框距照片上端的距离,以像素为单位

  • left (int)

    圈人框距照片左端的距离,以像素为单位

  • frame_width (int)

    圈人框的宽度,以像素为单位

  • frame_height (int)

    圈人框的高度,以像素为单位

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

Options Hash (opts):

  • :tagged_user_id (int)

    被圈用户的ID,该ID对应用户必须与session_key对应用户为好友关系

  • :tagged_user_name (String)

    被圈用户的名字,若被圈的人没有人人用户ID时,可以传递user_name参数

See Also:



125
126
127
128
129
130
131
132
133
134
135
# File 'lib/renren2/interface/photos.rb', line 125

def tag(photo_id, owner_id, photo_width, photo_height, top, left, frame_width, frame_height, opts={})
  check_scope "send_request"
  post 'photos.tag', :body => {:photo_id => photo_id,
                               :owner_id => owner_id,
                               :photo_width => photo_width,
                               :photo_height => photo_height,
                               :top => top,
                               :left => left,
                               :frame_width => frame_width,
                               :frame_height => frame_height}.merge(opts)
end

#upload(upload, content_type, opts = {}) ⇒ Object

Note:

require “photo_upload” scope

上传照片到用户的相册,同时返回这张照片的信息

Parameters:

  • upload (String)

    待上传照片路径

  • content_type (String)

    待上传照片格式

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

Options Hash (opts):

  • :caption (String)

    照片的描述信息

  • :aid (int)

    相册的ID,如果指定此参数,将会传到指定相册,默认传到手机相册

  • :place_id (String)

    上传照片所在地点的ID

See Also:



52
53
54
55
# File 'lib/renren2/interface/photos.rb', line 52

def upload(upload, content_type, opts={})
  check_scope "photo_upload"
  post 'photos.upload', :body => {:upload => Faraday::UploadIO.new(upload, content_type)}.merge(opts)
end