The latest version of the Facebook PHP SDK makes it easy to get a long-lived
access_token, giving you access to the user’s profile for up to 60 days, opposed to 1-2 hours with the regular
access_token. The long-lived
access_token can be used to perform tasks on the user’s behalf for long periods of time, for example, accessing check-in data for up to 60 days.
setExtendedAccessToken() function exchanges the user’s short-lived access token for a long-lived one in just a few short lines of code:
The long-lived access_token means the user doesn’t need to login to your application for an extended period of time. In addition, using the long-lived access token with the
manage_pages permission gives you access to page tokens that do not expire.
Just like short-lived access token, the long-lived token expires if the user changes their password, deauthorizes an app, or logs out. In these cases, the app should handle errors gracefully.