本文整理汇总了Python中twitter.Twitter.get_tweepy_API方法的典型用法代码示例。如果您正苦于以下问题:Python Twitter.get_tweepy_API方法的具体用法?Python Twitter.get_tweepy_API怎么用?Python Twitter.get_tweepy_API使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.Twitter
的用法示例。
在下文中一共展示了Twitter.get_tweepy_API方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from twitter import Twitter [as 别名]
# 或者: from twitter.Twitter import get_tweepy_API [as 别名]
def main():
if args.twitter:
t = Twitter(args)
t.login()
t.get_tweepy_API()
if args.command == 'read':
t.read()
elif args.command == 'post':
t.post()
else:
t.delete()
if args.facebook:
f = Facebook(args)
f.login()
f.get_facepy_API()
if args.command == 'read':
f.read()
elif args.command == 'post':
f.post()
else:
f.delete()
示例2: TestTwitter
# 需要导入模块: from twitter import Twitter [as 别名]
# 或者: from twitter.Twitter import get_tweepy_API [as 别名]
class TestTwitter(unittest.TestCase):
def setUp(self):
# simulate "psh -t read" command args
args = Namespace(cargs='home', command='read', facebook=False, media='', number=10, status='', twitter=True, verbose=False)
self.t = Twitter(args)
self.t.login()
def test_login(self):
# Tests login() & indirectly, known_user_auth()
# and first_time_auth() by checking the access
# token of 'self.auth'
# read in access token from 'twitter-access-token.txt'
with open('twitter-access-token.txt', 'r') as infile:
content = infile.readlines()
access_token = content[0].rstrip()
access_token_secret = content[1].rstrip()
self.assertEqual(self.t.auth.access_token, access_token)
self.assertEqual(self.t.auth.access_token_secret, access_token_secret)
def test_get_tweepy_API(self):
# Tests get_tweepy_API & verify() indirectly
self.assertFalse(isinstance(self.t.api, tweepy.API))
self.t.get_tweepy_API()
self.assertTrue(isinstance(self.t.api, tweepy.API))
def test_statuses_to_tweets(self):
self.t.get_tweepy_API()
statuses = self.t.api.home_timeline(count=self.t.args.number)
tweets = self.t.statuses_to_tweets(statuses)
# check first element, assume the rest are the same
self.assertTrue(isinstance(tweets[0], tweet.Tweet))
tweets = self.t.statuses_to_tweets([])
self.assertFalse(tweets)