class Test(unittest.TestCase): consumer_key='' consumer_secret='' def __init__(self): """ constructor """ def getAtt(self, key): try: return self.obj.__getattribute__(key) except Exception as e: print(e) return '' def auth(self): if len(self.consumer_key) == 0: print("Please set consumer_key£¡£¡£¡") return if len(self.consumer_key) == 0: print("Please set consumer_secret£¡£¡£¡") return self.auth = OAuthHandler(self.consumer_key, self.consumer_secret) auth_url = self.auth.get_authorization_url() print('Please authorize: ' + auth_url) verifier = input('PIN: ').strip() self.auth.get_access_token(verifier) self.api = API(self.auth) def setAccessToken(self, key, secret): self.auth = OAuthHandler(self.consumer_key, self.consumer_secret) self.auth.setAccessToken(key, secret) self.api = API(self.auth) def update(self, message): status = self.api.update_status(message) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update,id="+ str(id) +",text="+ text) def destroy_status(self, id): status = self.api.destroy_status(id) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update---"+ str(id) +":"+ text)
class Test(unittest.TestCase): consumer_key = '' consumer_secret = '' def __init__(self): """ constructor """ def getAtt(self, key): try: return self.obj.__getattribute__(key) except Exception as e: print(e) return '' def auth(self): if len(self.consumer_key) == 0: print("Please set consumer_key£¡£¡£¡") return if len(self.consumer_key) == 0: print("Please set consumer_secret£¡£¡£¡") return self.auth = OAuthHandler(self.consumer_key, self.consumer_secret) auth_url = self.auth.get_authorization_url() print('Please authorize: ' + auth_url) verifier = input('PIN: ').strip() self.auth.get_access_token(verifier) self.api = API(self.auth) def setAccessToken(self, key, secret): self.auth = OAuthHandler(self.consumer_key, self.consumer_secret) self.auth.setAccessToken(key, secret) self.api = API(self.auth) def update(self, message): status = self.api.update_status(message) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update,id=" + str(id) + ",text=" + text) def destroy_status(self, id): status = self.api.destroy_status(id) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update---" + str(id) + ":" + text)
class Test(unittest.TestCase): consumer_key='' consumer_secret='' def __init__(self): """ constructor """ def getAtt(self, key): try: return self.obj.__getattribute__(key) except Exception as e: print(e) return '' def getAttValue(self, obj, key): try: return obj.__getattribute__(key) except Exception as e: print(e) return '' def basicAuth(self, source, username, password): self.authType = 'basicauth' self.auth = BasicAuthHandler(username, password) self.api = API(self.auth,source=source) def update(self, message): status = self.api.update_status(message) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update---"+ str(id) +":"+ text) def destroy_status(self, id): status = self.api.destroy_status(id) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update---"+ str(id) +":"+ text)
class Test(unittest.TestCase): consumer_key = '' consumer_secret = '' def __init__(self): """ constructor """ def getAtt(self, key): try: return self.obj.__getattribute__(key) except Exception as e: print(e) return '' def setAccessToken(self, key, secret): self.auth = OAuthHandler(self.consumer_key, self.consumer_secret) self.auth.setAccessToken(key, secret) self.api = API(self.auth) def basicAuth(self, source, username, password): self.auth = BasicAuthHandler(username, password) self.api = API(self.auth, source=source) def update(self, message): status = self.api.update_status(lat='39', long='110', status=message) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update---" + str(id) + ":" + text) def destroy_status(self, id): status = self.api.destroy_status(id) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update---" + str(id) + ":" + text)
class Test(unittest.TestCase): consumer_key='' consumer_secret='' def __init__(self): """ constructor """ def getAtt(self, key): try: return self.obj.__getattribute__(key) except Exception as e: print(e) return '' def setAccessToken(self, key, secret): self.auth = OAuthHandler(self.consumer_key, self.consumer_secret) self.auth.setAccessToken(key, secret) self.api = API(self.auth) def basicAuth(self, source, username, password): self.auth = BasicAuthHandler(username, password) self.api = API(self.auth,source=source) def update(self, message): status = self.api.update_status(lat='39', long='110', status=message) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update---"+ str(id) +":"+ text) def destroy_status(self, id): status = self.api.destroy_status(id) self.obj = status id = self.getAtt("id") text = self.getAtt("text") print("update---"+ str(id) +":"+ text)