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


Python API.retweets_of_me方法代码示例

本文整理汇总了Python中tweepy.API.retweets_of_me方法的典型用法代码示例。如果您正苦于以下问题:Python API.retweets_of_me方法的具体用法?Python API.retweets_of_me怎么用?Python API.retweets_of_me使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tweepy.API的用法示例。


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

示例1: TweepyApi

# 需要导入模块: from tweepy import API [as 别名]
# 或者: from tweepy.API import retweets_of_me [as 别名]

#.........这里部分代码省略.........
        By default, 20 tweets are fetched. If provided, `count` controls how
        many tweets are requested.
        """
        older = self.get_user_timeline(screen_name,
                                       max_id=tweet_id,
                                       count=count/2)
        newer = self.get_user_timeline(screen_name,
                                       since_id=tweet_id,
                                       count=count/2)
        return older + newer

    def get_message_thread(self, dm, **kwargs):
        messages = self.get_direct_messages(**kwargs)

        me = self.verify_credentials()
        if dm.sender_screen_name == me.screen_name:
            with_user = dm.recipient_screen_name
        else:
            with_user = dm.sender_screen_name

        def belongs_to_conversation(message):
            return (message.sender_screen_name == with_user or
                    message.recipient_screen_name == with_user)

        return filter(belongs_to_conversation, messages)

    @to_status_from_search
    @include_entities
    def search(self, text, **kwargs):
        return self._api.search(text, **kwargs)

    @to_status
    @include_entities
    def get_retweets_of_me(self, **kwargs):
        return self._api.retweets_of_me(**kwargs)

    def update(self, text):
        self._api.update_status(text)

    def reply(self, status, text):
        self._api.update_status(text, in_reply_to_status_id=status.id)

    def destroy_status(self, status):
        self._api.destroy_status(status.id)

    def retweet(self, status):
        self._api.retweet(status.id)

    def direct_message(self, username, text):
        self._api.send_direct_message(user=username, text=text)

    def destroy_direct_message(self, dm):
        self._api.destroy_direct_message(dm.id)

    def create_friendship(self, screen_name):
        self._api.create_friendship(screen_name=screen_name)

    def destroy_friendship(self, screen_name):
        self._api.destroy_friendship(screen_name=screen_name)

    def create_favorite(self, status):
        self._api.create_favorite(status.id)

    def destroy_favorite(self, status):
        self._api.destroy_favorite(status.id)
开发者ID:floppym,项目名称:turses,代码行数:69,代码来源:backends.py

示例2: handle

# 需要导入模块: from tweepy import API [as 别名]
# 或者: from tweepy.API import retweets_of_me [as 别名]
def handle(text, mic, profile):
    
    consumer_key = profile['twitter']["TW_CONSUMER_KEY"]
    consumer_secret = profile['twitter']["TW_CONSUMER_SECRET"]
    access_token = profile['twitter']["TW_ACCESS_TOKEN"]
    access_token_secret = profile['twitter']["TW_ACCESS_TOKEN_SECRET"]
    woeid = int(profile['twitter']["WOEID"])
    
    try:
        auth = OAuthHandler(consumer_key, consumer_secret)
        auth.set_access_token(access_token, access_token_secret)
        api = API(auth)
        myTwitterID = api.me().id
    except Exception as e:
        print e
        mic.say("Connection Error. Twitter service is offline.")
        return
        
    directMessages = api.direct_messages(count=1)
    latestRetweet = 0
    latestMention = 0
    latestDirectMessage = 0

    try:
        directMessageIDFile = open(jasperpath.data('twitter', 'directMessageID.txt'),'r')
        directMessageID = directMessageIDFile.readline()
        latestDirectMessage = int(directMessageID)
        directMessageIDFile.close()
    except IOError:
        if len(directMessages) > 0:
            for directMessage in directMessages:
                latestDirectMessage = directMessage.id
            directMessageIDFile = open(jasperpath.data('twitter', 'directMessageID.txt'),'w')
            directMessageIDFile.write(str(latestDirectMessage))
            directMessageIDFile.close()

    mentions = api.mentions_timeline(count=1)

    try:
        mentionIDFile = open(jasperpath.data('twitter', 'mentionIDFile.txt'),'r')
        latestMentionID = mentionIDFile.readline()
        latestMention = int(latestMentionID)
        mentionIDFile.close()
    except IOError:
        if len(mentions) > 0:
            mentionIDFile = open(jasperpath.data('twitter', 'mentionIDFile.txt'),'w')
            for mention in mentions:
                latestMention = mention.id
            mentionIDFile.write(str(latestMention))
            mentionIDFile.close()

    retweets = api.retweets_of_me(count=1)

    try:
        retweetsIDFile = open(jasperpath.data('twitter', 'retweetsIDFile.txt'),'r')
        retweetsID = retweetsIDFile.readline()
        latestRetweet = int(retweetsID)
        retweetsIDFile.close()
    except IOError:
        if len(retweets) > 0:        
            retweetsIDFile = open(jasperpath.data('twitter', 'retweetsIDFile.txt'),'w')
            for retweet in retweets:
                latestRetweet = retweet.id
            retweetsIDFile.write(str(latestRetweet))
            retweetsIDFile.close()

    if bool(re.search(r'\bTWEET\b', text, re.IGNORECASE)):
        sendTweet(mic, api)

    if bool(re.search(r'\bNOTIFICATIONS\b', text, re.IGNORECASE)):
        getNotifications(mic,latestRetweet,latestMention,latestDirectMessage, api)

    if bool(re.search(r'\bTRENDING\b', text, re.IGNORECASE)):
        getWhatsTrending(mic, api, woeid)
        
    if bool(re.search(r'\bTWEETS\b', text, re.IGNORECASE)):
        getPublicTweets(mic, api)
开发者ID:G10DRAS,项目名称:JasperModules,代码行数:79,代码来源:Twitter.py

示例3: TweepyAPITests

# 需要导入模块: from tweepy import API [as 别名]
# 或者: from tweepy.API import retweets_of_me [as 别名]
class TweepyAPITests(unittest.TestCase):

    def setUp(self):
        auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
        auth.set_access_token(oauth_token, oauth_token_secret)
        self.api = API(auth)
        self.api.retry_count = 2
        self.api.retry_delay = 5

    def testhometimeline(self):
        self.api.home_timeline()

    def testfriendstimeline(self):
        self.api.friends_timeline()

    def testusertimeline(self):
        self.api.user_timeline()
        self.api.user_timeline('twitter')

    def testmentions(self):
        self.api.mentions()

    def testretweetedbyme(self):
        self.api.retweeted_by_me()

    def testretweetedbyuser(self):
        self.api.retweeted_by_user('twitter')

    def testretweetedtome(self):
        self.api.retweeted_to_me()

    def testretweetsofme(self):
        self.api.retweets_of_me()

    def testretweet(self):
        s = self.api.retweet(test_tweet_id)
        s.destroy()

    def testretweets(self):
        self.api.retweets(test_tweet_id)

    def testgetstatus(self):
        self.api.get_status(id=test_tweet_id)

    def testupdateanddestroystatus(self):
        # test update
        text = 'testing %i' % random.randint(0, 1000)
        update = self.api.update_status(status=text)
        self.assertEqual(update.text, text)

        # test destroy
        deleted = self.api.destroy_status(id=update.id)
        self.assertEqual(deleted.id, update.id)

    def testgetuser(self):
        u = self.api.get_user('twitter')
        self.assertEqual(u.screen_name, 'twitter')

        u = self.api.get_user(783214)
        self.assertEqual(u.screen_name, 'twitter')

    def testsearchusers(self):
        self.api.search_users('twitter')

    def testme(self):
        me = self.api.me()
        self.assertEqual(me.screen_name, username)

    def testfriends(self):
        self.api.friends()

    def testfollowers(self):
        self.api.followers()

    def testdirectmessages(self):
        self.api.direct_messages()

    def testsentdirectmessages(self):
        self.api.sent_direct_messages()

    def testsendanddestroydirectmessage(self):
        # send
        sent_dm = self.api.send_direct_message(username, text='test message')
        self.assertEqual(sent_dm.text, 'test message')
        self.assertEqual(sent_dm.sender.screen_name, username)
        self.assertEqual(sent_dm.recipient.screen_name, username)

        # destroy
        destroyed_dm = self.api.destroy_direct_message(sent_dm.id)
        self.assertEqual(destroyed_dm.text, sent_dm.text)
        self.assertEqual(destroyed_dm.id, sent_dm.id)
        self.assertEqual(destroyed_dm.sender.screen_name, username)
        self.assertEqual(destroyed_dm.recipient.screen_name, username)

    def testcreatedestroyfriendship(self):
        enemy = self.api.destroy_friendship('twitter')
        self.assertEqual(enemy.screen_name, 'twitter')

        # Wait 5 seconds to allow Twitter time
        # to process the friendship destroy request.
#.........这里部分代码省略.........
开发者ID:Kudo,项目名称:tweepy,代码行数:103,代码来源:tests.py

示例4: TweepyApi

# 需要导入模块: from tweepy import API [as 别名]
# 或者: from tweepy.API import retweets_of_me [as 别名]

#.........这里部分代码省略.........
    #  it uses `TweepyApi.get_user_timeline` which is already
    #  decorated
    @include_entities
    def get_thread(self, status, **kwargs):
        """
        Get the conversation to which `status` belongs.

        It filters the last tweets by the participanting users and
        based on mentions to each other.
        """
        author = status.authors_username
        mentioned = status.mentioned_usernames
        if author not in mentioned:
            mentioned.append(author)

        tweets = []
        for username in mentioned:
            tweets.extend(self.get_user_timeline(username, **kwargs))

        def belongs_to_conversation(status):
            for username in mentioned:
                if username in status.text:
                    return True

        return filter(belongs_to_conversation, tweets)

    @to_status_from_search
    @include_entities
    def search(self, text, **kwargs):
        return self._api.search(text, **kwargs)

    @to_status
    @include_entities
    def get_retweets_of_me(self, **kwargs):
        return self._api.retweets_of_me(**kwargs)

    def update(self, text):
        self._api.update_status(text)

    def destroy_status(self, status):
        self._api.destroy_status(status.id)

    def retweet(self, status):
        self._api.retweet(status.id)

    def direct_message(self, username, text):
        self._api.send_direct_message(user=username, text=text)

    def destroy_direct_message(self, dm):
        self._api.destroy_direct_message(dm.id)

    def create_friendship(self, screen_name):
        self._api.create_friendship(screen_name=screen_name)

    def destroy_friendship(self, screen_name):
        self._api.destroy_friendship(screen_name=screen_name)

    def create_favorite(self, status):
        self._api.create_favorite(status.id)

    def destroy_favorite(self, status):
        self._api.destroy_favorite(status.id)

    # list methods

    @to_list
开发者ID:replicant0wnz,项目名称:turses,代码行数:70,代码来源:backends.py

示例5: TweepyAPITests

# 需要导入模块: from tweepy import API [as 别名]
# 或者: from tweepy.API import retweets_of_me [as 别名]
class TweepyAPITests(unittest.TestCase):
    def setUp(self):
        auths = []
        for consumer_key, consumer_secret, access_key, access_secret in oauth_keys:
            auth = OAuthHandler(consumer_key, consumer_secret)
            auth.set_access_token(access_key, access_secret)
            auths.append(auth)

        self.api = API(auths)
        self.api.retry_count = 2
        self.api.retry_delay = 5

    # TODO: Actually have some sort of better assertion
    def testgetoembed(self):
        data = self.api.get_oembed(test_tweet_id)
        self.assertEqual(data["author_name"], "Twitter")

    def testhometimeline(self):
        self.api.home_timeline()

    def testusertimeline(self):
        self.api.user_timeline()
        self.api.user_timeline("twitter")

    def testmentionstimeline(self):
        self.api.mentions_timeline()

    def testretweetsofme(self):
        self.api.retweets_of_me()

    def testretweet(self):
        # TODO(josh): Need a way to get random tweets to retweet.
        raise SkipTest()

    def testretweets(self):
        self.api.retweets(test_tweet_id)

    def testgetstatus(self):
        self.api.get_status(id=test_tweet_id)

    def testupdateanddestroystatus(self):
        # test update
        text = "testing %i" % random.randint(0, 1000)
        update = self.api.update_status(status=text)
        self.assertEqual(update.text, text)

        # test destroy
        deleted = self.api.destroy_status(id=update.id)
        self.assertEqual(deleted.id, update.id)

    def testgetuser(self):
        u = self.api.get_user("twitter")
        self.assertEqual(u.screen_name, "twitter")

        u = self.api.get_user(783214)
        self.assertEqual(u.screen_name, "twitter")

    def testsearchusers(self):
        self.api.search_users("twitter")

    def testsuggestedcategories(self):
        self.api.suggested_categories()

    def testsuggestedusers(self):
        categories = self.api.suggested_categories()
        if len(categories) != 0:
            self.api.suggested_users(categories[0].slug)

    def testsuggesteduserstweets(self):
        categories = self.api.suggested_categories()
        if len(categories) != 0:
            self.api.suggested_users_tweets(categories[0].slug)

    def testme(self):
        me = self.api.me()
        self.assertEqual(me.screen_name, username)

    def testdirectmessages(self):
        self.api.direct_messages()

    def testsentdirectmessages(self):
        self.api.sent_direct_messages()

    def testsendanddestroydirectmessage(self):
        # send
        sent_dm = self.api.send_direct_message(username, text="test message")
        self.assertEqual(sent_dm.text, "test message")
        self.assertEqual(sent_dm.sender.screen_name, username)
        self.assertEqual(sent_dm.recipient.screen_name, username)

        # destroy
        destroyed_dm = self.api.destroy_direct_message(sent_dm.id)
        self.assertEqual(destroyed_dm.text, sent_dm.text)
        self.assertEqual(destroyed_dm.id, sent_dm.id)
        self.assertEqual(destroyed_dm.sender.screen_name, username)
        self.assertEqual(destroyed_dm.recipient.screen_name, username)

    def testcreatedestroyfriendship(self):
        enemy = self.api.destroy_friendship("twitter")
        self.assertEqual(enemy.screen_name, "twitter")
#.........这里部分代码省略.........
开发者ID:QiaozhiWang,项目名称:tweepy,代码行数:103,代码来源:tests.py


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