本文整理汇总了Python中pyfb.Pyfb.get_friends方法的典型用法代码示例。如果您正苦于以下问题:Python Pyfb.get_friends方法的具体用法?Python Pyfb.get_friends怎么用?Python Pyfb.get_friends使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyfb.Pyfb
的用法示例。
在下文中一共展示了Pyfb.get_friends方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyfbTests
# 需要导入模块: from pyfb import Pyfb [as 别名]
# 或者: from pyfb.Pyfb import get_friends [as 别名]
class PyfbTests(unittest.TestCase):
pyfb_args = {}
def setUp(self):
self.pyfb = Pyfb(config["FACEBOOK_APP_ID"], **self.pyfb_args)
self.pyfb.set_access_token(config["FACEBOOK_TOKEN"])
self.me = self.pyfb.get_myself()
def test_auth(self):
self.assertEquals(type(self.me.name), type(unicode()))
def test_get_friends(self):
self.assertTrue(isinstance(self.pyfb.get_friends(self.me.id), list))
def test_get_photos_paging(self):
photos = self.pyfb.get_photos()
more_photos = photos.next()
more_more_photos = more_photos.next()
if len(photos) < 25 and len(more_photos) > 0:
raise Exception()
if len(photos) == 25 and len(more_photos) < 25 and len(more_more_photos) > 0:
raise Exception()
self.assertTrue(isinstance(photos, list))
self.assertTrue(isinstance(more_photos, list))
self.assertTrue(isinstance(more_more_photos, list))
self.assertEquals(len(photos), len(more_photos.previous()))
self.assertEquals(photos.previous(), [])
示例2: pyfbTests
# 需要导入模块: from pyfb import Pyfb [as 别名]
# 或者: from pyfb.Pyfb import get_friends [as 别名]
class pyfbTests(unittest.TestCase):
def setUp(self):
self.facebook = Pyfb(FACEBOOK_APP_ID)
self.facebook.set_access_token(FACEBOOK_TOKEN)
self.me = self.facebook.get_myself()
def test_auth(self):
self.assertEquals(type(self.me.name), type(unicode()))
def test_get_friends(self):
self.assertEquals(type(self.facebook.get_friends(self.me.id)), type(list()))
示例3: Pyfb
# 需要导入模块: from pyfb import Pyfb [as 别名]
# 或者: from pyfb.Pyfb import get_friends [as 别名]
"""
from pyfb import Pyfb
#Your APP ID. You Need to register the application on facebook
#http://developers.facebook.com/
#FACEBOOK_APP_ID = 'YOUR_APP_ID'
FACEBOOK_APP_ID = ''
facebook = Pyfb(FACEBOOK_APP_ID)
#Opens a new browser tab instance and authenticates with the facebook API
#It redirects to an url like http://www.facebook.com/connect/login_success.html#access_token=[access_token]&expires_in=0
#facebook.authenticate()
#Copy the [access_token] and enter it below
token = ''
#raw_input("Enter the access_token\n")
#Sets the authentication token
facebook.set_access_token(token)
#Gets info about myself
me = facebook.get_myself()
print "-" * 40
print "Name: %s" % me.name
print
print "Friends list:"
for i in facebook.get_friends():
print i.name
示例4: raw_input
# 需要导入模块: from pyfb import Pyfb [as 别名]
# 或者: from pyfb.Pyfb import get_friends [as 别名]
#Opens a new browser tab instance and authenticates with the facebook API
#It redirects to an url like http://www.facebook.com/connect/login_success.html#access_token=[access_token]&expires_in=0
#facebook.authenticate()
#Copy the [access_token] and enter it below
#token = raw_input("Enter the access_token\n")
token = ''
#Sets the authentication token
facebook.set_access_token(token)
#Gets info about myself
me = facebook.get_myself()
f = codecs.open("friends.txt", "w", "utf-8")
friends = facebook.get_friends()
for friend in friends:
f.write(friend.name)
f.write(":")
f.write(friend.id)
f.write(":")
try:
f.write(getHometown(friend).encode('utf8'))
except:
f.write(" ")
f.write("\n")
f.close()