当前位置: 首页>>代码示例>>Python>>正文


Python auth.BasicAuthHandler类代码示例

本文整理汇总了Python中weibopy.auth.BasicAuthHandler的典型用法代码示例。如果您正苦于以下问题:Python BasicAuthHandler类的具体用法?Python BasicAuthHandler怎么用?Python BasicAuthHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BasicAuthHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Test

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))
开发者ID:chengjun,项目名称:Research,代码行数:32,代码来源:unread.py

示例2: Test

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)
开发者ID:chengjun,项目名称:Research,代码行数:31,代码来源:mention.py

示例3: test

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)
开发者ID:chengjun,项目名称:Research,代码行数:31,代码来源:getFriends.py

示例4: Test

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)
开发者ID:chengjun,项目名称:Research,代码行数:32,代码来源:upload.py

示例5: Test

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)        
开发者ID:chengjun,项目名称:Research,代码行数:35,代码来源:privacy.py

示例6: Test

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))
开发者ID:rahulsoni9,项目名称:Research,代码行数:33,代码来源:counts.py

示例7: Test

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)
开发者ID:chengjun,项目名称:Research,代码行数:57,代码来源:getTimelines.py

示例8: Test

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)                        
开发者ID:chengjun,项目名称:Research,代码行数:56,代码来源:tags.py

示例9: Test

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)
开发者ID:chengjun,项目名称:Research,代码行数:55,代码来源:directMessages.py

示例10: Test

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)
开发者ID:chengjun,项目名称:Research,代码行数:50,代码来源:friendships.py

示例11: Test

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)
开发者ID:chengjun,项目名称:Research,代码行数:46,代码来源:favorites.py

示例12: __init__

 def __init__(self, username, password, listener, timeout=5.0, retry_count = None,
                 retry_time = 10.0, snooze_time = 5.0, buffer_size=1500, headers=None):
     self.auth = BasicAuthHandler(username, password)
     self.running = False
     self.timeout = timeout
     self.retry_count = retry_count
     self.retry_time = retry_time
     self.snooze_time = snooze_time
     self.buffer_size = buffer_size
     self.listener = listener
     self.api = API()
     self.headers = headers or {}
     self.body = None
开发者ID:ybak,项目名称:myblog,代码行数:13,代码来源:streaming.py

示例13: Test

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))
开发者ID:chengjun,项目名称:Research,代码行数:39,代码来源:ids.py

示例14: Test

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)
开发者ID:chengjun,项目名称:Research,代码行数:36,代码来源:oauthSetTokenUpdate.py

示例15: basicAuth

 def basicAuth(self, source, username, password):
     self.authType = 'basicauth'
     self.auth = BasicAuthHandler(username, password)
     self.api = API(self.auth,source=source)
开发者ID:chengjun,项目名称:Research,代码行数:4,代码来源:tags.py


注:本文中的weibopy.auth.BasicAuthHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。