本文整理汇总了Python中facebook.Facebook.get_facepy_API方法的典型用法代码示例。如果您正苦于以下问题:Python Facebook.get_facepy_API方法的具体用法?Python Facebook.get_facepy_API怎么用?Python Facebook.get_facepy_API使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类facebook.Facebook
的用法示例。
在下文中一共展示了Facebook.get_facepy_API方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from facebook import Facebook [as 别名]
# 或者: from facebook.Facebook import get_facepy_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: TestFacebook
# 需要导入模块: from facebook import Facebook [as 别名]
# 或者: from facebook.Facebook import get_facepy_API [as 别名]
class TestFacebook(unittest.TestCase):
def setUp(self):
# simulate "psh -f read" command args
args = Namespace(cargs='home', command='read', facebook=True, media='', number=10, status='', twitter=False, verbose=False)
self.f = Facebook(args)
self.f.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 'facebook-access-token.txt'
with open('facebook-access-token.txt', 'r') as infile:
content = infile.readlines()
access_token = content[0].rstrip()
access_token_secret = content[1].rstrip()
self.assertEqual(self.f.auth.access_token, access_token)
self.assertEqual(self.f.auth.access_token_secret, access_token_secret)
def test_get_facepy_API(self):
# Tests get_facepy_API & verify() indirectly
self.assertFalse(isinstance(self.f.api, facepy.API))
self.f.get_facepy_API()
self.assertTrue(isinstance(self.f.api, facepy.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)