Reputation: 33996
This is my current code to request permission to see email and user_photos
'req_perms' => 'email,user_photos',
I want to access user photos when the user is offline, I seem to remember this was possible but maybe I am wrong. Anyway if it's possible, how is it done?
Upvotes: 0
Views: 297
Reputation: 17720
Hyunmin (in comments) has the right link.
As a very quick summary:
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.
Upvotes: 1