使Facebook访问权限永远不会过期2016年Facebook SDK? [英] Making Page Access Tokens Never Expire With 2016 Facebook SDK?

查看:93
本文介绍了使Facebook访问权限永远不会过期2016年Facebook SDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在构建的应用程序是iOS和Android移动应用程序,可将高中学生与非营利组织配对,以帮助管理他们的Facebook页面。我们将每个学生分配给一个非营利组织,使他们成为他们Facebook页面的管理员,并允许他们代表组织创建职位,以吸引新的受众。然后,每个学生都会获得一个比分,其中包括学生在页面上发帖的喜好,评论,分享等。

The application we are building is both an iOS and Android mobile app that pairs high school students with nonprofits to help manage their Facebook pages. We assign each student to one nonprofit, make them an administrator of their Facebook page, and allow them to create posts on behalf of the organization to reach new audiences. Each student is then given a score that comprises of the likes, comments, shares, etc. garnered by the student's posts on the page.

我们遇到的麻烦是Facebook Graph API。我们需要熟悉当前Facebook SDK的人员,帮助我们制定更好的计划来检索特定数据。

The trouble we are having is with the Facebook Graph API. We need someone familiar with the current Facebook SDK that can help us devise a better plan to retrieve specific data.

目前,我们已经创建了一个管理员非营利的Facebook页面在我们的平台上。我们使用此管理员访问权限来检索每个Facebook页面的用户访问令牌和页面访问令牌。但是使用新的SDK,我们只能在页面上访问令牌最近60天,不断刷新令牌来检索数据。但是,当我们刷新时,Facebook要求我们使用用户名和密码进行身份验证,从而使服务器崩溃的风险很高。此外,这种方法增加了我们对Facebook数据的每日请求数量,因为在我们向应用添加更多用户时,Facebook可能会关闭我们的访问风险。

Currently, we have made a profile that is an admin for every nonprofit Facebook page on our platform. We use this admin access to retrieve a user access token and a page access token for each Facebook page. But with the new SDK, we can only make page access tokens last 60 days, making us constantly have to refresh the token to retrieve the data. However, when we refresh, Facebook asks us to authenticate with a username and password which slows down our backend with high a risk of our server crashing. Also, this method increases the amount of daily requests we make to Facebook for data, running the risk that Facebook might shut down our access completely as we add more users to the app.

所以我们的问题真的在于这个页面访问令牌,因为我们正在尝试从多个不同的Facebook页面查询数据。我们要求的数据也是非常具体的,因为我们只希望从页面上的特定admin_creator发布的帖子中的数据(也就是学生,而不是其他管理员)分配学生的分数。

So our problem really lies with this page access token because we are trying to query data from multiple different Facebook pages. The data we are requesting is also very specific because we only want the data from posts published from a specific "admin_creator" on the page (aka the student only, not any other admin) to assign the student a score.

有没有办法让页面访问令牌永远不会与当前的Facebook SDK过期?有帖子描述这个过程,但是它们是2014年,而不是当前版本。另外还有比现在更好的方法来检索我们需要的具体数据吗?

Is there a way to make page access tokens never expire with the current Facebook SDK? There are posts that describe this process, but they were for 2014, not the current version. Also, is there a better way than our current method to retrieve the specific data we need?

推荐答案

步骤:


  1. 获取权限为 manage_pages 用户访问令牌它。

  2. 扩展令牌(使用服务器端,因为它涉及应用程序秘密)

  1. Get the user-access-token having the permission manage_pages with it.
  2. Extend the token using (do it server side, since it involves app secret)

https://graph.facebook.com / oauth / access_token?grant_type = fb_exchange_token& client_id = {your_app_id}& client_secret = {your_app_secret}& fb_exchange_token = {user_token_from_last_step}

https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id={your_app_id}&client_secret={your_app_secret}&fb_exchange_token={user_token_from_last_step}


  • 使用上述步骤中的扩展令牌,并使用API​​ -

  • Use the extended token from above step and use the API-

    /v2.5/{page-id}?fields=access_token
    

    您将获得页面访问令牌<

    You'll get the page access token in response, that'll never expire.

    我认为你在第2步,只是按照步骤3,你很好去。

    I think you're at step 2, just follow the step 3 and you're good to go.

    我建议你通过此页面关于访问令牌和事情将会更清楚。

    I'll recommend you go through this page about the access tokens and things will be much clearer.

    这篇关于使Facebook访问权限永远不会过期2016年Facebook SDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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