我从事的一个项目将Facebook页面作为其数据源之一。它周期性地从它导入一些数据,不涉及GUI。然后我们使用一个网络应用程序来显示我们已经拥有的数据。

并非所有信息都是公开的。这意味着我必须访问一次数据,然后保存它。然而,我不知道这个过程,我还没有找到一个好的教程。我想我需要一个access_token,我怎么能从用户得到它,一步一步?用户是一个facebook页面的管理员,他是否必须添加一些我们的FB应用程序的页面?

编辑:感谢@phwd的提示。我做了一个教程,如何获得一个永久的页面访问令牌,即使offline_access不再存在。

编辑:我刚刚发现它的答案在这里:持久的FB访问令牌服务器拉FB页面信息


当前回答

以下是我的解决方案,只使用图形API资源管理器和访问令牌调试器:

Graph API Explorer: Select your App from the top right dropdown menu Select "Get User Access Token" from dropdown (right of access token field) and select needed permissions Copy user access token Access Token Debugger: Paste copied token and press "Debug" Press "Extend Access Token" and copy the generated long-lived user access token Graph API Explorer: Paste copied token into the "Access Token" field Make a GET request with "PAGE_ID?fields=access_token" Find the permanent page access token in the response (node "access_token") (Optional) Access Token Debugger: Paste the permanent token and press "Debug" "Expires" should be "Never"

(API版本2.9-2.11,3.0-3.1测试)

其他回答

由于所有早期的答案都是旧的,并且由于facebook的政策不断变化,其他提到的答案可能不适用于永久代币。

经过大量的调试,我能够获得永不过期令牌使用以下步骤:

图形API浏览器:

Open graph api explorer and select the page for which you want to obtain the access token in the right-hand drop-down box, click on the Send button and copy the resulting access_token, which will be a short-lived token Copy that token and paste it in access token debugger and press debug button, in the bottom of the page click on extend token link, which will extend your token expiry to two months. Copy that extended token and paste it in the below url with your pageId, and hit in the browser url https://graph.facebook.com/{page_id}?fields=access_token&access_token={long_lived_token} U can check that token in access token debugger tool and verify Expires field , which will show never.

这是它

如果只请求页数据,则可以使用页访问令牌。您只需授权用户一次即可获得用户访问令牌;将有效期延长到两个月,然后请求该页的令牌。这在场景5中都有解释。请注意,获取的页面访问令牌仅在用户访问令牌有效期间有效。

除了在Vlasec回答中推荐的步骤,您还可以使用:

图形API资源管理器进行查询,例如/{pageId}?= access_token&access_token = THE_ACCESS_TOKEN_PROVIDED_BY_GRAPH_EXPLORER字段 访问令牌调试器以获取有关访问令牌的信息。

如果你有facebook的应用,那么你可以尝试app-id和app-secret。

如:

access_token={your-app_id}|{your-app_secret}

它不需要频繁地更改令牌。

我找到了这个答案,它指的是这个工具,它真的很有用。

我希望当你读到这篇文章时,这个答案仍然有效。