def unfollow(entity,lastid=""): """unfollow entity get ent['id'] first from followers and unfollow that id NOT WORKING """ conf=config.config() app = login.login() if lastid: debug('unfollow: Have lastid: %s'%(lastid)) getf = app.getFollowers(since_id=lastid) else: debug('unfollow: Have NO lastid') getf = app.getFollowers() for ent in getf: lastid=ent['id'] debug('lastid in loop = %s'%(lastid)) if ent['entity']==entity: debug('found entity match: %s and %s'%(ent['entity'],entity)) try: app.unfollow(ent['id']) debug('unfollowed: %s'%(entity)) return True except Exception, e: debug('error unfollowing: %s' % (entity)) debug(e) return False else: debug('%s is not the same as %s'%(ent['entity'],entity))
def test_login(): print "\ntest005" print "=======" print "description: login to server" print "testobject: def login" print "input: " print "output: profile" print "result:" print pprint.pformat(login.login(test=1))
def follow(entity): """follow entity""" conf=config.config() app = login.login() f=app.follow(str(entity)) if f: return True else: retstring = "Could not follow %s" % (entity,e) return retstring
def sendpost(message): """send post to server""" conf = libconfig.config() app = liblogin.login() post = { # add split message if > 256 char "type": "https://tent.io/types/post/status/v0.1.0", "published_at": int(time.time()), "permissions": { # add private as option "public": True }, # this should be read from config file "licenses": [""], "app": {"name": "Tentog"}, "content": {"text": message}, } try: app.putPost(post) except Exception, e: libfunc.debug("something went wrong posting: \n%s" % (message)) libfunc.debug(e)