예제 #1
0
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 repost(self, id, message):
        status = self.api.repost(id, message)
        self.obj = status
        id = self.getAtt("id")
        text = self.getAtt("text")
        print("repost---" + str(id) + ":" + text)
예제 #2
0
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, source=self.consumer_key)

    def basicAuth(self, source, username, password):
        self.authType = "basicauth"
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth, source=source)

    def counts(self):
        counts = self.api.counts(ids="1864372538,1484854960,1877120192")
        for count in counts:
            self.obj = count
            mid = self.getAtt("id")
            comments = self.getAtt("comments")
            rt = self.getAtt("rt")
            print("mentions---" + str(mid) + ":" + str(comments) + ":" + str(rt))
예제 #3
0
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 mentions(self):
        comments = self.api.mentions()
        for comment in comments:
            self.obj = comment
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("mentions---"+ str(mid) +":"+ text)
예제 #4
0
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 friends(self):
        timeline = self.api.friends()
        for line in timeline:
            self.obj = line
            fid = self.getAtt("id")
            name = self.getAtt("screen_name")
            print("friends---"+ str(fid) +":"+ name)
예제 #5
0
파일: unread.py 프로젝트: chengjun/Research
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 unread(self):
        count = self.api.unread()
        self.obj = count
        mentions = self.getAtt("mentions")
        comments = self.getAtt("comments")
        followers = self.getAtt("followers")
        dm = self.getAtt("dm")
        print("mentions---"+ str(mentions) +":"+ str(comments) +":"+ str(followers) +":"+ str(dm))
예제 #6
0
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, source=self.consumer_key)

    def basicAuth(self, source, username, password):
        self.authType = 'basicauth'
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth, source=source)

    def counts(self):
        counts = self.api.counts(ids='1864372538,1484854960,1877120192')
        for count in counts:
            self.obj = count
            mid = self.getAtt("id")
            comments = self.getAtt("comments")
            rt = self.getAtt("rt")
            print("mentions---" + str(mid) + ":" + str(comments) + ":" +
                  str(rt))
예제 #7
0
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, source=self.consumer_key)

    def basicAuth(self, source, username, password):
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth, source=source)

    def update_profile_image(self, filename):
        user = self.api.update_profile_image(filename)
        self.obj = user
        id = self.getAtt("id")
        profile_image_url = self.getAtt("profile_image_url")
        print("update,uid=" + str(id) + ",profile_image_url=" +
              profile_image_url)
예제 #8
0
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 unread(self):
        count = self.api.unread()
        self.obj = count
        mentions = self.getAtt("mentions")
        comments = self.getAtt("comments")
        followers = self.getAtt("followers")
        dm = self.getAtt("dm")
        print("mentions---" + str(mentions) + ":" + str(comments) + ":" +
              str(followers) + ":" + str(dm))
예제 #9
0
파일: upload.py 프로젝트: chengjun/Research
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, source=self.consumer_key)
        
    def basicAuth(self, source, username, password):
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth,source=source)
    
    def upload(self, filename, message):
        status = self.api.upload(filename, status=message)        
        self.obj = status
        id = self.getAtt("id")
        text = self.getAtt("text")
        self.obj = self.getAtt("user")
        profile_image_url  = self.getAtt("profile_image_url")
        print("upload,id="+ str(id) +",text="+ text +",profile_image_url="+ profile_image_url)
예제 #10
0
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 friends(self):
        timeline = self.api.friends()
        for line in timeline:
            self.obj = line
            fid = self.getAtt("id")
            name = self.getAtt("screen_name")
            print("friends---" + str(fid) + ":" + name)
예제 #11
0
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, source=self.consumer_key)
        
    def basicAuth(self, source, username, password):
        self.authType = 'basicauth'
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth,source=source)
    def get_privacy(self):
        privacy = self.api.get_privacy()
        self.obj = privacy
        ct = self.getAtt("comment")
        dm = self.getAtt("dm")
        real_name = self.getAtt("real_name")
        geo = self.getAtt("geo")
        badge = self.getAtt("badge") 
        print ("privacy---"+ str(ct) + str(dm) + str(real_name) + str(geo) + str(badge))
    def update_privacy(self):
        update_privacy = self.api.update_privacy(comment=0)        
예제 #12
0
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 friends_timeline(self):
        timeline = self.api.friends_timeline(count=2, page=1)
        for line in timeline:
            self.obj = line
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("friends_timeline---" + str(mid) + ":" + text)

    def comments_timeline(self):
        timeline = self.api.comments_timeline(count=2, page=1)
        for line in timeline:
            self.obj = line
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("comments_timeline---" + str(mid) + ":" + text)

    def user_timeline(self):
        timeline = self.api.user_timeline(count=5, page=1)
        for line in timeline:
            self.obj = line
            mid = self.getAtt("id")
            text = self.getAtt("text")
            created_at = self.getAtt("created_at")
            print("user_timeline---" + str(mid) + ":" + str(created_at) + ":" +
                  text)
        timeline = self.api.user_timeline(count=20, page=2)

    def public_timeline(self):
        timeline = self.api.public_timeline(count=2, page=1)
        for line in timeline:
            self.obj = line
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("public_timeline---" + str(mid) + ":" + text)
예제 #13
0
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 direct_message(self):
        messages = self.api.direct_messages()
        mid = ''
        for msg in messages:
            self.obj = msg
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("direct_message---" + str(mid) + ":" + text)
        return mid

    def sent_direct_messages(self):
        messages = self.api.sent_direct_messages()
        for msg in messages:
            self.obj = msg
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("sent_direct_messages---" + str(mid) + ":" + text)

    def new_direct_message(self):
        msg = self.api.new_direct_message(id=1114365581,
                                          text='directMessages--test-²âÊÔ-' +
                                          str(time.time()))
        self.obj = msg
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print("new_direct_message---" + str(mid) + ":" + text)

    def destroy_direct_message(self, id):
        msg = self.api.destroy_direct_message(id)
        self.obj = msg
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print("destroy_direct_message---" + str(mid) + ":" + text)
예제 #14
0
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 friends_timeline(self):
        timeline = self.api.friends_timeline(count=2, page=1)
        for line in timeline:
            self.obj = line
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("friends_timeline---"+ str(mid) +":"+ text)

    def comments_timeline(self):
        timeline = self.api.comments_timeline(count=2, page=1)
        for line in timeline:
            self.obj = line
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("comments_timeline---"+ str(mid) +":"+ text)
            
    def user_timeline(self):
        timeline = self.api.user_timeline(count=5, page=1)
        for line in timeline:
            self.obj = line
            mid = self.getAtt("id")
            text = self.getAtt("text")
            created_at = self.getAtt("created_at")
            print("user_timeline---"+ str(mid) +":"+ str(created_at)+":"+ text)
        timeline = self.api.user_timeline(count=20, page=2)
        
    def public_timeline(self):
        timeline = self.api.public_timeline(count=2, page=1)
        for line in timeline:
            self.obj = line
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("public_timeline---"+ str(mid) +":"+ text)
예제 #15
0
파일: tags.py 프로젝트: shunsunsun/Research
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, source=self.consumer_key)
        
    def basicAuth(self, source, username, password):
        self.authType = 'basicauth'
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth,source=source)
    def tags(self):
        tags = self.api.tags(user_id=1377583044)
        for line in tags:
            self.obj = line
            tagid=self.getAtt("id")
            value = self.getAtt(tagid)
            print (tagid,value)
    def tag_create(self ,message):
#        message = message.encode("utf-8")
        tag_create = self.api.tag_create(tags=message)
        for line in tag_create:
            self.obj = line
            tagid = self.getAtt("tagid")
            print ("tag_create---"+tagid)
    def tag_suggestions(self):
        tag_suggestions=self.api.tag_suggestions()
        for line in tag_suggestions:
            self.obj = line
            id = self.getAtt("id")
            value = self.getAtt("value")
            print ("tag_suggestions---"+ id +":"+ value)
    def tag_destroy(self,tag_id):
        tag_destroy=self.api.tag_destroy(tag_id)
        self.obj=tag_destroy
        result=self.getAtt("result")
        print ("tag_destroy---"+ result)
    def tag_destroy_batch(self,tag_ids):
        tag_destroy_batch=self.api.tag_destroy_batch(tag_ids)
        for line in tag_destroy_batch:
            self.obj = line
            tagid=self.getAtt("tagid")
            print ("tag_destroy_batch---"+ tagid)                        
예제 #16
0
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 direct_message(self):
        messages = self.api.direct_messages()
        mid = ''
        for msg in messages:
            self.obj = msg
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("direct_message---"+ str(mid) +":"+ text)
        return mid
    
    def sent_direct_messages(self):
        messages = self.api.sent_direct_messages()
        for msg in messages:
            self.obj = msg
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("sent_direct_messages---"+ str(mid) +":"+ text)
            
    def new_direct_message(self):
        msg = self.api.new_direct_message(id=1114365581,text='directMessages--test-²âÊÔ-'+ str(time.time()))
        self.obj = msg
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print("new_direct_message---"+ str(mid) +":"+ text)
            
    def destroy_direct_message(self, id):
        msg = self.api.destroy_direct_message(id)
        self.obj = msg
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print("destroy_direct_message---"+ str(mid) +":"+ text)
예제 #17
0
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 create_friendship(self):
        user = self.api.create_friendship(id=1114365581)
        self.obj = user
        uid = self.getAtt("id")
        screen_name = self.getAtt("screen_name")
        print("create_friendship---" + str(uid) + ":" + screen_name)

    def destroy_friendship(self):
        user = self.api.destroy_friendship(id=1114365581)
        self.obj = user
        uid = self.getAtt("id")
        screen_name = self.getAtt("screen_name")
        print("destroy_friendship---" + str(uid) + ":" + screen_name)

    def exists_friendship(self):
        self.obj = self.api.exists_friendship(user_a=1772333754,
                                              user_b=1773365880)
        friends = self.getAtt("friends")
        print("exists_friendship--- " + str(friends))

    def show_friendship(self, uid):
        showList = self.api.show_friendship(target_id=uid)
        for obj in showList:
            self.obj = obj
            uid = self.getAtt("id")
            screen_name = self.getAtt("screen_name")
            print("show_friendship---" + str(uid) + ":" + screen_name)
예제 #18
0
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 create_friendship(self):
        user = self.api.create_friendship(id=1114365581)
        self.obj = user
        uid = self.getAtt("id")
        screen_name = self.getAtt("screen_name")
        print("create_friendship---"+ str(uid) +":"+ screen_name)
        
    def destroy_friendship(self):
        user = self.api.destroy_friendship(id=1114365581)
        self.obj = user
        uid = self.getAtt("id")
        screen_name = self.getAtt("screen_name")
        print("destroy_friendship---"+ str(uid) +":"+ screen_name)
        
    def exists_friendship(self):
        self.obj = self.api.exists_friendship(user_a=1772333754, user_b=1773365880)
        friends = self.getAtt("friends")
        print("exists_friendship--- "+ str(friends))
        
    def show_friendship(self, uid):
        showList = self.api.show_friendship(target_id=uid)
        for obj in showList:
            self.obj = obj
            uid = self.getAtt("id")
            screen_name = self.getAtt("screen_name")
            print("show_friendship---"+ str(uid) +":"+ screen_name)
예제 #19
0
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.authType = 'basicauth'
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth,source=source)
        
    def favorites(self):
        statuses = self.api.favorites(id=1773365880)
        for status in statuses:
            self.obj = status
            sid = self.getAtt("id")
            text = self.getAtt("text")
            print("favorites---"+ str(sid) +":"+ text)
        
    def create_favorite(self, id):
        status = self.api.create_favorite(id)
        self.obj = status
        sid = self.getAtt("id")
        text = self.getAtt("text")
        print("create_favorite---"+ str(sid) +":"+ text)
            
    def destroy_favorite(self, id):
        msg = self.api.destroy_favorite(id)
        self.obj = msg
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print("destroy_favorite---"+ str(mid) +":"+ text)
예제 #20
0
파일: ids.py 프로젝트: shunsunsun/Research
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 friends_ids(self):
        fids = self.api.friends_ids()
        self.obj = fids
        ids = self.getAtt("ids")
        next_cursor = self.getAtt("next_cursor")
        previous_cursor = self.getAtt("previous_cursor")
        print("friends_ids---" + str(ids) + ":next_cursor" + str(next_cursor) +
              ":previous_cursor" + str(previous_cursor))

    def followers_ids(self):
        fids = self.api.followers_ids()
        self.obj = fids
        ids = self.getAtt("ids")
        next_cursor = self.getAtt("next_cursor")
        previous_cursor = self.getAtt("previous_cursor")
        print("followers_ids---" + str(ids) + ":next_cursor" +
              str(next_cursor) + ":previous_cursor" + str(previous_cursor))
예제 #21
0
파일: ids.py 프로젝트: chengjun/Research
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 friends_ids(self):
        fids = self.api.friends_ids()
        self.obj = fids
        ids = self.getAtt("ids")
        next_cursor = self.getAtt("next_cursor")
        previous_cursor = self.getAtt("previous_cursor")
        print("friends_ids---"+ str(ids) +":next_cursor"+ str(next_cursor) +":previous_cursor"+ str(previous_cursor))
        
    def followers_ids(self):
        fids = self.api.followers_ids()
        self.obj = fids
        ids = self.getAtt("ids")
        next_cursor = self.getAtt("next_cursor")
        previous_cursor = self.getAtt("previous_cursor")
        print("followers_ids---"+ str(ids) +":next_cursor"+ str(next_cursor) +":previous_cursor"+ str(previous_cursor))
예제 #22
0
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, source=self.consumer_key)

    def basicAuth(self, source, username, password):
        self.authType = 'basicauth'
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth, source=source)

    def get_privacy(self):
        privacy = self.api.get_privacy()
        self.obj = privacy
        ct = self.getAtt("comment")
        dm = self.getAtt("dm")
        real_name = self.getAtt("real_name")
        geo = self.getAtt("geo")
        badge = self.getAtt("badge")
        print("privacy---" + str(ct) + str(dm) + str(real_name) + str(geo) +
              str(badge))

    def update_privacy(self):
        update_privacy = self.api.update_privacy(comment=0)
예제 #23
0
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)
예제 #24
0
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, source=self.consumer_key)

    def basicAuth(self, source, username, password):
        self.authType = 'basicauth'
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth, source=source)

    def comments(self, id):
        comments = self.api.comments(id=id)
        for comment in comments:
            self.obj = comment
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("comments---" + str(mid) + ":" + text)

    def comments_timeline(self):
        comments = self.api.comments_timeline()
        for comment in comments:
            self.obj = comment
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("comments_timeline---" + str(mid) + ":" + text)

    def comments_by_me(self):
        comments = self.api.comments_by_me(count=5)
        mid = ''
        for comment in comments:
            self.obj = comment
            mid = self.getAtt("id")
            text = self.getAtt("text")
            created_at = self.getAtt("created_at")
            print('comments_by_me,id=' + str(mid) + ',text=' + text +
                  ',created_at=' + str(created_at))
        return mid

    def comment(self, mid):
        comment = self.api.comment(id=mid,
                                   comment='commect-test-²âÊÔ--' +
                                   str(time.time()))
        self.obj = comment
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print("comment---" + str(mid) + ":" + text)

    def comment_destroy(self, mid):
        comment = self.api.comment_destroy(mid)
        self.obj = comment
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print("comment_destroy---" + str(mid) + ":" + text)
예제 #25
0
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, source=self.consumer_key)
        
    def basicAuth(self, source, username, password):
        self.authType = 'basicauth'
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth,source=source)
        
    def comments(self, id):
        comments = self.api.comments(id=id)
        for comment in comments:
            self.obj = comment
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("comments---"+ str(mid) +":"+ text)
    
    def comments_timeline(self):
        comments = self.api.comments_timeline()
        for comment in comments:
            self.obj = comment
            mid = self.getAtt("id")
            text = self.getAtt("text")
            print("comments_timeline---"+ str(mid) +":"+ text)
    
    def comments_by_me(self):
        comments = self.api.comments_by_me(count=5)
        mid = ''
        for comment in comments:
            self.obj = comment
            mid = self.getAtt("id")
            text = self.getAtt("text")
            created_at = self.getAtt("created_at")
            print('comments_by_me,id='+ str(mid) +',text='+ text+',created_at='+ str(created_at))
        return mid
    
    def comment(self, mid):
        comment = self.api.comment(id=mid, comment='commect-test-²âÊÔ--'+ str(time.time()))
        self.obj = comment
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print("comment---"+ str(mid) +":"+ text)
    
    def comment_destroy (self, mid):
        comment = self.api.comment_destroy(mid)
        self.obj = comment
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print("comment_destroy---"+ str(mid) +":"+ text)
예제 #26
0
파일: trends.py 프로젝트: chengjun/Research
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, source=self.consumer_key)
        
    def basicAuth(self, source, username, password):
        self.authType = 'basicauth'
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth,source=source)
    
    def trends(self):
        trends = self.api.trends(user_id=1377583044,count=20, page=1)
#        print str(len(trends))
        for line in trends:
            self.obj=line
            num = self.getAtt("num")
            trend_id = self.getAtt("trend_id")
            hotword = self.getAtt("hotword")
            print ("trends---"+ num +":"+ hotword +":"+trend_id)
    def trends_statuses(self , message):
        message = message.encode("utf-8")
        trends_statuses = self.api.trends_statuses(message)
        for line in trends_statuses:
            self.obj=line
            id = self.getAtt("id")
            text = self.getAtt("text")
            print ("ToReader---"+ str(id) + ":" +text)
#            print text 
    def trends_follow(self , message):
        message = message.encode("utf-8")
        trends_follow = self.api.trends_follow(message)
    def trends_destroy(self , id):
        trends_destroy=self.api.trends_destroy(id)
    def trends_hourly(self):
        trends_hourly = self.api.trends_hourly(base_app=0)
        self.obj=trends_hourly
        query = self.getAtt("trends")
        as_of = self.getAtt("as_of")
        for key in query:
            key = time.strftime('%Y-%m-%d',time.localtime(as_of))
            for line in query[key]:
                query = line["query"]
                name = line["name"]
                print ("trends_hourly---"+"Query:" + query+",Name:"+ name)
    def trends_daily(self):
        trends_daily=self.api.trends_daily(base_app=0)
        self.obj=trends_daily
        query=self.getAtt("trends")
        as_of=self.getAtt("as_of")
        for key in query:
            key=time.strftime('%Y-%m-%d',time.localtime(as_of))
            for line in query[key]:
                query=line["query"]
                name=line["name"]
                print ("trends_daily---"+"Query:" + query+",Name:"+ name) 
    def trends_weekly(self):
        trends_weekly=self.api.trends_weekly(base_app=0)
        self.obj=trends_weekly
        query=self.getAtt("trends")
        as_of=self.getAtt("as_of")
        for key in query:
            key = time.strftime('%Y-%m-%d',time.localtime(as_of))
            for line in query[key]:
                query=line["query"]
                name=line["name"]  
                print ("trends_weekly---"+"Query:" + query+",Name:"+ name)  
예제 #27
0
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, source=self.consumer_key)

    def basicAuth(self, source, username, password):
        self.authType = 'basicauth'
        self.auth = BasicAuthHandler(username, password)
        self.api = API(self.auth, source=source)

    def trends(self):
        trends = self.api.trends(user_id=1377583044, count=20, page=1)
        #        print str(len(trends))
        for line in trends:
            self.obj = line
            num = self.getAtt("num")
            trend_id = self.getAtt("trend_id")
            hotword = self.getAtt("hotword")
            print("trends---" + num + ":" + hotword + ":" + trend_id)

    def trends_statuses(self, message):
        message = message.encode("utf-8")
        trends_statuses = self.api.trends_statuses(message)
        for line in trends_statuses:
            self.obj = line
            id = self.getAtt("id")
            text = self.getAtt("text")
            print("ToReader---" + str(id) + ":" + text)


#            print text

    def trends_follow(self, message):
        message = message.encode("utf-8")
        trends_follow = self.api.trends_follow(message)

    def trends_destroy(self, id):
        trends_destroy = self.api.trends_destroy(id)

    def trends_hourly(self):
        trends_hourly = self.api.trends_hourly(base_app=0)
        self.obj = trends_hourly
        query = self.getAtt("trends")
        as_of = self.getAtt("as_of")
        for key in query:
            key = time.strftime('%Y-%m-%d', time.localtime(as_of))
            for line in query[key]:
                query = line["query"]
                name = line["name"]
                print("trends_hourly---" + "Query:" + query + ",Name:" + name)

    def trends_daily(self):
        trends_daily = self.api.trends_daily(base_app=0)
        self.obj = trends_daily
        query = self.getAtt("trends")
        as_of = self.getAtt("as_of")
        for key in query:
            key = time.strftime('%Y-%m-%d', time.localtime(as_of))
            for line in query[key]:
                query = line["query"]
                name = line["name"]
                print("trends_daily---" + "Query:" + query + ",Name:" + name)

    def trends_weekly(self):
        trends_weekly = self.api.trends_weekly(base_app=0)
        self.obj = trends_weekly
        query = self.getAtt("trends")
        as_of = self.getAtt("as_of")
        for key in query:
            key = time.strftime('%Y-%m-%d', time.localtime(as_of))
            for line in query[key]:
                query = line["query"]
                name = line["name"]
                print("trends_weekly---" + "Query:" + query + ",Name:" + name)