扩展 Facebook 页面访问令牌 [英] Extending Facebook Page Access Token

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

问题描述

我需要扩展我的 facebook 访问令牌,我称之为:

i need to extend my facebook access token, I'm calling this:

https://graph.facebook.com/oauth/access_token? 
client_id={MY PAGE ID}&
client_secret={THE SECRET KEY OF MY APP}&
grant_type=fb_exchange_token&
fb_exchange_token={AN ACCESS TOKEN FOR MY PAGE}

我收到此错误:

   "error": {
      "message": "Error validating application. Cannot get application info due to a system error.",
      "type": "OAuthException",
      "code": 101
   }

我看到这个 access_token 有很多问题,但没有与页面相关的答案,idk 为什么 facebook 使用 api 那为什么......但就是这样......

I've seen a lot of problem with that access_token, but none answer relative to pages, idk why facebook use api that why... but is the way...

谢谢,

推荐答案

要获得长期访问令牌,您需要按照以下步骤操作:

To get a long-lived access token you need to follow those steps:

  1. 创建应用程序
  2. 创建主页(您的帐户需要是主页的管理员")
  3. 将应用程序与页面相关联(与向页面添加页面选项卡时的操作方式相同)

  1. Create an Application
  2. Create a Page (your account need to be "administrator" of the page)
  3. Associate the application to the Page (the same way you do it when you want to add a Page Tab to a Page)

http://facebook.com/add.php?api_key=*YOUR_APP_ID*&pages=1&page=*YOUR_PAGE_ID*

  • 获取具有与您的应用程序关联的manage_pages"权限的短期访问令牌.

  • Get a short-lived access token with the permission "manage_pages" associated to your Application.

    https://graph.facebook.com/oauth/authorize?client_id=__APP_ID__&scope=manage_pages&redirect_uri=http://www.facebook.com/connect/login_success.html
    then
    https://graph.facebook.com/oauth/access_token?client_id=__APP_ID__&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=__APP_SECRET__&code=__CODE_FROM_PREVIOUS_REQUEST__
    

  • 使用带有请求的 Graph API Explorer /me/accounts 您可以看到您作为管理员的每个页面的访问令牌.问题是这些访问令牌是短暂的.

  • Using the Graph API Explorer with the request /me/accounts you can see the access tokens for each Pages that you are administrator. The problem is that those access token are short-lived.

    将您的短期访问令牌转换为长期(扩展访问令牌):

    Convert your short-lived access token to a long-lived (extending access token):

    https://graph.facebook.com/oauth/access_token?client_id=_APP_ID_&client_secret=_APP_SECRET_&grant_type=fb_exchange_token&fb_exchange_token=_ACCESS_TOKEN_ON_STEP_4_
    

  • 您现在可以使用Access Token Debugger测试您的新访问令牌.

    这篇关于扩展 Facebook 页面访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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