提要离线访问 [英] Feed Offline Access

查看:101
本文介绍了提要离线访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,当用户转到该应用程序时,可以在其供稿中搜索特定的帖子. (我有read_stream).但是我需要该应用程序随时读取他们的供稿,例如每小时一次.没有他们的应用程序,我该如何阅读他们的提要?

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 ?

推荐答案

每次用户进入您的应用程序时,您必须在数据库上保存fb_id,并且必须保存扩展令牌.该令牌的有效期为60天,因此,每次用户访问您的应用时,您都应续签该令牌,这种方式不会过期.

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.

我不知道您是否正在使用PHP SDK,但是这是获取Facebook扩展令牌的方法:

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.

现在,下次您要离线阅读用户供稿时,只需从数据库中获取用户ID,然后

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);

这篇关于提要离线访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆