Feed Offline Access

岁酱吖の 提交于 2019-12-13 20:04:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!