scogley / SmartPhotoFrame

Smart Photo Frame displays your favorite pictures from social media and web apps. Uses Raspberry Pi 2 and connected 7" touch display
0 stars 0 forks source link

Investigate: How to fetch more than 25 photos from fb #7

Open scogley opened 8 years ago

scogley commented 8 years ago

currently I am retrieving only 25 photos when contacting the graph api photos edge me/photos. need to determine how to get more.

scogley commented 8 years ago

this is from code sample on facebook-sdk github get_posts.py. It shows using a while loop and requests to get the next page of data.

Wrap this block in a while loop so we can keep paginating requests until

finished.

while True: try:

Perform some action on each post in the collection we receive from

    # Facebook.
    [some_action(post=post) for post in posts['data']]
    # Attempt to make a request to the next page of data, if it exists.
    posts = requests.get(posts['paging']['next']).json()
except KeyError:
    # When there are no more pages (['paging']['next']), break from the
    # loop and end the script.
    break