SNSAPI Pluggins (Specifics for Different Platform)

Sina

Sina Weibo client

class snsapi.plugin.sina.SinaWeiboBase(channel=None)
static new_channel(full=False)
read_channel(channel)
need_auth()
auth_first()
auth_second()
weibo_request(*al, **ad)

General request method for Weibo V2 Api via OAuth.

Parameters:
  • name – The Api name shown on main page (http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2). e.g. friendships/create (no “2/” prefix)
  • method – HTTP request method: ‘GET’ or ‘POST’
  • params – Parameters from Api doc. No need to manually put access_token in.
Returns:

The http response from SinaWeibo (a JSON compatible structure).

NOTE: This method require authorization before invokation.

class snsapi.plugin.sina.SinaWeiboStatusMessage(dct=None, platform=None, channel=None, conf={})
platform = 'SinaWeiboStatus'
parse()
class snsapi.plugin.sina.SinaWeiboStatus(channel=None)
Message

alias of SinaWeiboStatusMessage

home_timeline(*al, **ad)

Get home timeline

Parameters:count – number of statuses

NOTE: This method require authorization before invokation.

update(*al, **ad)

update a status

  • parameter text: the update message
  • return: success or not

NOTE: This method require authorization before invokation.

reply(*al, **ad)

reply to a status

  • parameter text: the comment text
  • return: success or not

NOTE: This method require authorization before invokation.

forward(*al, **ad)

Forward a status on SinaWeibo:

  • If message is from the same platform, forward it using special interface.
  • Else, route the request to a general forward method of SNSBase.
  • Decorate the text with previous comment sequence.
Parameters:
  • message – An snstype.Message object to forward
  • text – Append comment text
Returns:

Success or not

NOTE: This method require authorization before invokation.

Tencent

Tencent Weibo Client

class snsapi.plugin.tencent.TencentWeiboStatusMessage(dct=None, platform=None, channel=None, conf={})
platform = 'TencentWeiboStatus'
parse()
class snsapi.plugin.tencent.TencentWeiboStatus(channel=None)
Message

alias of TencentWeiboStatusMessage

static new_channel(full=False)
read_channel(channel)
need_auth()
auth_first()
auth_second()
home_timeline(*al, **ad)

Get home timeline

  • function : get statuses of yours and your friends’
  • parameter count: number of statuses

NOTE: This method require authorization before invokation.

update(*al, **ad)

update a status

  • parameter text: the update message
  • return: success or not

NOTE: This method require authorization before invokation.

reply(*al, **ad)

reply to a status

  • parameter text: the comment text
  • return: success or not

NOTE: This method require authorization before invokation.

Renren

Renren Client

Codes are adapted from following sources:
exception snsapi.plugin.renren.RenrenAPIError(code, message)
class snsapi.plugin.renren.RenrenBase(channel=None)
static new_channel(full=False)

docstring placeholder

read_channel(channel)

docstring placeholder

need_auth()

docstring placeholder

auth_first()

docstring placeholder

auth_second()

docstring placeholder

auth()

docstring placeholder

renren_request(params=None)

A general purpose encapsulation of renren API. It fills in system paramters and compute the signature.

class snsapi.plugin.renren.RenrenShareMessage(dct=None, platform=None, channel=None, conf={})
platform = 'RenrenShare'
parse()
class snsapi.plugin.renren.RenrenShare(channel=None)
Message

alias of RenrenShareMessage

static new_channel(full=False)

docstring placeholder

home_timeline(*al, **ad)

Get timeline of Renren statuses

Parameters:count – Number of statuses
Returns:At most count statuses (can be less).

NOTE: This method require authorization before invokation.

reply(*al, **ad)

docstring placeholder

NOTE: This method require authorization before invokation.

class snsapi.plugin.renren.RenrenStatusMessage(dct=None, platform=None, channel=None, conf={})
platform = 'RenrenStatus'
parse()
class snsapi.plugin.renren.RenrenStatus(channel=None)
Message

alias of RenrenStatusMessage

static new_channel(full=False)
home_timeline(*al, **ad)

Get home timeline get statuses of yours and your friends’ @param count: number of statuses

NOTE: This method require authorization before invokation.

update(*al, **ad)

update a status @param text: the update message @return: success or not

NOTE: This method require authorization before invokation.

reply(*al, **ad)

reply status @param status: StatusID object @param text: string, the reply message @return: success or not

NOTE: This method require authorization before invokation.

forward(*al, **ad)

Forward a status on Renren:

  • If message is from the same platform, forward it using special interface.
  • Else, route the request to a general forward method of SNSBase.
Parameters:
  • message – An snstype.Message object to forward
  • text – Append comment text
Returns:

Success or not

NOTE: This method require authorization before invokation.

class snsapi.plugin.renren.RenrenBlogMessage(dct=None, platform=None, channel=None, conf={})
platform = 'RenrenBlog'
parse()
class snsapi.plugin.renren.RenrenBlog(channel=None)
Message

alias of RenrenBlogMessage

static new_channel(full=False)
home_timeline(*al, **ad)

Get blog timeline

Parameters:count – Number of blogs

NOTE: This method require authorization before invokation.

update(*al, **ad)

Post a blog

Parameters:
  • text – Blog post body.
  • title – Blog post title. (optional)
Returns:

success or not

NOTE: This method require authorization before invokation.

reply(*al, **ad)

Reply a renren blog

Parameters:
  • mID – MessageID object
  • text – string, the reply message
Returns:

success or not

NOTE: This method require authorization before invokation.

RSS

RSS Feed

Contains:
  • RSS Read-only feed platform.
  • RSS Read/Write platform.
  • RSS Summary platform.
class snsapi.plugin.rss.RSSMessage(dct=None, platform=None, channel=None, conf={})
platform = 'RSS'
parse()
dump_full()

Override Message.dump_full because default .raw attribute of RSSMessage object is not JSON serializable.

Note: dumpped messages are meant for the consumption of other languages. We do not concern how to convert back. If you do that, make sure call str2obj on .raw yourself. Besides, make sure the source of the string is trustful.

For the use in Python, directly serialize the message for persistent storage. Do not recommend you use any of the three level of dump_xxx functions. Use of digest_xxx is OK.

class snsapi.plugin.rss.RSS(channel=None)
Supported Methods
  • auth() :

    a NULL stub.

  • home_timeline() :

    read and parse RSS feed. pretend it to be a ‘special’ SNS platform, where you can only read your wall but can not write to it.

Message

alias of RSSMessage

static new_channel(full=False)
read_channel(channel)
auth()
auth_first()
auth_second()
home_timeline(count=20)

Get home timeline

  • function : get statuses of yours and your friends’
  • parameter count: number of statuses
expire_after(token=None)
class snsapi.plugin.rss.RSS2RWMessage(dct=None, platform=None, channel=None, conf={})
platform = 'RSS2RW'
parse()
class snsapi.plugin.rss.RSS2RW(channel=None)

Read/Write Channel for rss2

Message

alias of RSS2RWMessage

static new_channel(full=False)
read_channel(channel)
update(message)
Parameters:message (Message or str) – For Message update it directly. RSS2RW guarantee the message can be read back with the same values in standard fields of Message.parsed. For str, we compose the virtual Message first using current time and configured author information.
class snsapi.plugin.rss.RSSSummaryMessage(dct=None, platform=None, channel=None, conf={})
platform = 'RSSSummary'
parse()
class snsapi.plugin.rss.RSSSummary(channel=None)

Summary Channel for RSS

It provides more meaningful ‘text’ field.

Message

alias of RSSSummaryMessage

static new_channel(full=False)

Project Versions

Table Of Contents

Previous topic

SNSAPI Middleware

Next topic

Sample Applications Written in SNSAPI

This Page