Hyunmin (in comments) has the right link.
As a very quick summary:
- log the user in normally; you'll get an access token. This may be a short lived or long lived (60 day) token - depends on login method being serverside or client-side (PHP or JS) but don't worry which you get.
- Note if you are worried: you can also check expiry if you like as the expiry is provided when you are given the access token. But I again skip this step.
Once a day you can extend the token back ot the full 60 days. Simply call
https://graph.facebook.com/oauth/access_token?
client_id=APP_ID&
client_secret=APP_SECRET&
grant_type=fb_exchange_token&
fb_exchange_token=EXISTING_ACCESS_TOKEN
and you get back an access token (may or may not be the same). Just use/store this new access token in place of the old one.
Actually really simple - except for the bit of tracking the "once per day" upgrade bit. (And for now you can ignore this and call multiple times if needed - just slows things down fractionally.)
In response to comment - "how do you call that URL that gives you the token?"
You don't redirect the user as it's you that needs the response value, so you need to call it and handle it.
In PHP the simplest for testing (but not recommended) is to use
$response = file_get_contents($url);
but on production systems you should usse CURL (as some production systems don't allow file_get_contents for external URLs). Either google for a CURL example, or you could tap into the makeRequest() function in the included facebook SDK libraries.