當前位置: 首頁>>代碼示例>>Python>>正文


Python Pyfb.get_friends方法代碼示例

本文整理匯總了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(), [])
開發者ID:atul2512,項目名稱:pyfb,代碼行數:34,代碼來源:test.py

示例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()))
開發者ID:evandekieft,項目名稱:pyfb,代碼行數:14,代碼來源:test.py

示例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
開發者ID:eokeeffe,項目名稱:Python,代碼行數:33,代碼來源:Class20.py

示例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()

開發者ID:eokeeffe,項目名稱:Python,代碼行數:31,代碼來源:facebookMap.py


注:本文中的pyfb.Pyfb.get_friends方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。