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.

like(*al, **ad)
Like method
  • Weibo doesn’t provide an API for “like”
  • So “favourite” function supersedes “like”
  • Here “like” means “add to my favourites”
  • Receive a message

NOTE: This method require authorization before invokation.

unlike(*al, **ad)
Unlike method
  • Weibo doesn’t provide an API for “unlike”
  • So “unfavourite” function supersedes “unlike”
  • Here “unlike” means “remove from my favourites”
  • Receive a message

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()
tencent_request(method, http_method='GET', files={}, **kwargs)
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.

like(*al, **ad)

like a status

  • parameter message: the message to be liked
  • return: success or not

NOTE: This method require authorization before invokation.

unlike(*al, **ad)

unlike a status

  • parameter message: the message to be unliked
  • return: success or not

NOTE: This method require authorization before invokation.

Renren

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)