问题
I have an app that when the user goes to the app, searches his feed for specific posts. (I have read_stream). But i needed the app to read their feed whenever I want, like once an hour. How can i read their feed without they are in the app ?
回答1:
Every time the user, enters your app you must save is fb_id on your data_base and you must save the extended token. This token will be valid for 60 days, so everytime the user goes to your app you should renew it, this way won't expire.
I don't know if you're using PHP SDK but here's the way you can get the facebook extended token:
require_once("facebook.php");
$config = array();
$config[‘appId’] = 'YOUR_APP_ID';
$config[‘secret’] = 'YOUR_APP_SECRET';
$config[‘fileUpload’] = false; // optional
$facebook = new Facebook($config);
$facebook->setExtendedAccessToken();
$access_token = $facebook->getAccessToken();
$uid = $facebook->getUser();
//now that you have the extended token and the user id save it on your database.
Now the next time you want to read the feed of the user offline, just grab the user id from the database and
//the next time you want to read the user feed, just grab the uid from your database and access token and set it
$facebook->setAccessToken($new_access_token);
来源:https://stackoverflow.com/questions/15682974/feed-offline-access