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


Python Pyfb.get_photos方法代碼示例

本文整理匯總了Python中pyfb.Pyfb.get_photos方法的典型用法代碼示例。如果您正苦於以下問題:Python Pyfb.get_photos方法的具體用法?Python Pyfb.get_photos怎麽用?Python Pyfb.get_photos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyfb.Pyfb的用法示例。


在下文中一共展示了Pyfb.get_photos方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: PyfbTests

# 需要導入模塊: from pyfb import Pyfb [as 別名]
# 或者: from pyfb.Pyfb import get_photos [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: Pyfb

# 需要導入模塊: from pyfb import Pyfb [as 別名]
# 或者: from pyfb.Pyfb import get_photos [as 別名]
#http://developers.facebook.com/
FACEBOOK_APP_ID = 'YOUR_APP_ID'

pyfb = 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
pyfb.authenticate()

#Copy the [access_token] and enter it below
token = raw_input("Enter the access_token\n")

#Sets the authentication token
pyfb.set_access_token(token)

photos = pyfb.get_photos()

print "These are my photos:\n"
for photo in photos:
    print photo.picture

#Just call the method next to get the next page of photos!
more_photos = photos.next()

print "\nMore photos:\n"
for photo in more_photos:
    print photo.picture

more_more_photos = more_photos.next()

print "\nDo you want more?:\n"
開發者ID:Mondego,項目名稱:pyreco,代碼行數:33,代碼來源:allPythonContent.py


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