Exemplo n.º 1
0
def main():
    """docstring for main"""
    #set system default encoding to utf-8 to avoid encoding problems
    reload(sys)
    sys.setdefaultencoding( "utf-8" )
    
    #load channel configurations
    channels = json.load(open('conf/channel.json'))
    
    

    #find one account
    rr = SNSPocket()
    for c in channels:
        rr.add_channel(c)

    if rr is None:
        print "cannot find one renren platform in channel.json"
        return 
    else:
        rr.load_config()
        rr.auth()
        

    #load record to avoid repeated reply
    try:
        sIDs = json.load(open('statusID.json'))
    except IOError, e:
        if e.errno == 2: #no such file
            sIDs = {}
        else:
            raise e
Exemplo n.º 2
0
    SNSAPI. 

    '''
    if isinstance(t, str):
        return sp.update(console_input(t), *al, **ad)
    elif isinstance(t, snstype.Message):
        return sp.update(t, *al, **ad)
    else:
        logger.warning("unknown type: %s", type(t))

lc = load_config = lambda *al, **ad : sp.load_config(*al, **ad)
sc = save_config = lambda *al, **ad  : sp.save_config(*al, **ad)
lsc = list_channel = lambda  *al, **ad : sp.list_channel(*al, **ad)
lsp = list_platform = lambda  *al, **ad : sp.list_platform(*al, **ad)
newc = new_channel = lambda *al, **ad : sp.new_channel(*al, **ad)
addc = add_channel = lambda *al, **ad : sp.add_channel(*al, **ad)
clc = clear_channel = lambda *al, **ad : sp.clear_channel(*al, **ad)
auth = lambda  *al, **ad : sp.auth(*al, **ad)
ht = home_timeline = lambda *al, **ad : sp.home_timeline(*al, **ad)
up = update = lambda  t, *al, **ad : update_from_console(t, *al, **ad)
re = reply = lambda  m, t, *al, **ad : sp.reply(m, console_input(t), *al, **ad)
fwd = forward = lambda  m, t, *al, **ad : sp.forward(m, console_input(t), *al, **ad)

#==== documentation ====

helpdoc = \
"""
snscli -- the interactive CLI to operate all SNS!

Type "print helpdoc" again to see this document. 
Exemplo n.º 3
0
from snsapi import snstype
from snsapi.utils import console_output, console_input
from snsapi.snspocket import SNSPocket
from snsapi.snslog import SNSLog as logger

sp = SNSPocket()

#This is a much simpler and more clear test file. Hupili's tut file is too complex, and did not provide a `app_secret` and `app_key`

#Don't think too much just run, it will be all clear. ^_^

#xuanqinanhai 2013-1-25 14:43
sp.list_channel()

sp.clear_channel()
nc = sp.new_channel()
nc["platform"] = "SinaWeiboStatus"
nc["app_secret"] = "96bcc1e00268d7e415c32212b3e197fb" #this is my own app secret
nc["app_key"] = "3644324674" #and key
nc["channel_name"] = "test_weibo"
nc["auth_info"]["callback_url"] = "https://snsapi.ie.cuhk.edu.hk/aux/auth.php" #I changed the callback url in my app manage page.
sp.add_channel(nc)
sp.auth()
sp.save_config()
sp.list_channel()

status =  sp.home_timeline()
for each in status:
	print each,
	
Exemplo n.º 4
0
    '''
    if isinstance(t, str):
        return sp.update(console_input(t), *al, **ad)
    elif isinstance(t, snstype.Message):
        return sp.update(t, *al, **ad)
    else:
        logger.warning("unknown type: %s", type(t))


lc = load_config = lambda *al, **ad: sp.load_config(*al, **ad)
sc = save_config = lambda *al, **ad: sp.save_config(*al, **ad)
lsc = list_channel = lambda *al, **ad: sp.list_channel(*al, **ad)
lsp = list_platform = lambda *al, **ad: sp.list_platform(*al, **ad)
newc = new_channel = lambda *al, **ad: sp.new_channel(*al, **ad)
addc = add_channel = lambda *al, **ad: sp.add_channel(*al, **ad)
clc = clear_channel = lambda *al, **ad: sp.clear_channel(*al, **ad)
auth = lambda *al, **ad: sp.auth(*al, **ad)
ht = home_timeline = lambda *al, **ad: sp.home_timeline(*al, **ad)
up = update = lambda t, *al, **ad: update_from_console(t, *al, **ad)
re = reply = lambda m, t, *al, **ad: sp.reply(m, console_input(t), *al, **ad)
fwd = forward = lambda m, t, *al, **ad: sp.forward(m, console_input(t), *al, **
                                                   ad)

#==== documentation ====

helpdoc = \
"""
snscli -- the interactive CLI to operate all SNS!

Type "print helpdoc" again to see this document.