Facebook Graphi API 不会在离线模式下列出页面帐户

发布于 2024-11-03 18:59:33 字数 660 浏览 0 评论 0原文

我的离线 Facebook 应用程序正在尝试检索与先前授权该应用程序的特定用户 ID 关联的帐户:

https://graph.facebook.com/(userid)/accounts?access_token=(token)

即使我传递了有效的访问令牌,Facebook也会返回: OAuthException:请求此资源需要访问令牌。

我通过使用相同的用户 ID 和访问令牌查询 Likes 连接来验证我的访问令牌是否正确:

https://graph.facebook.com/(userid)/likes?access_token=(token)

对于第二个语句,Facebook 返回预期结果。

我的应用程序具有 Manage_pages 和 Offline_access 权限。访问令牌我我使用的是 Facebook 在用户授权应用程序时返回的访问令牌,我不明白为什么它适用于 Likes 连接,但不适用于帐户连接。

My offline Facebook application is trying to retrieve the accounts associated with a specific user id who has previously authorized the application:

https://graph.facebook.com/(userid)/accounts?access_token=(token)

Even though I am passing a valid access token, Facebook returns:
OAuthException: An access token is required to request this resource.

I verified that my access token is correct by querying the likes connection with the same userid and access token:

https://graph.facebook.com/(userid)/likes?access_token=(token)

For this second statement, Facebook returns the expected result.

My application has manage_pages and offline_access permissions. The access token I am using is the access token Facebook returned when the user authorized the application. I don't understand why it works for the likes connection but not for the accounts connection.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倥絔 2024-11-10 18:59:33

Facebook 提供不同的访问令牌,有些较短,有些较长。在没有意识到差异的情况下,我使用了较短的,创建为 type='client_cred'。这些可以很好地检索好友列表、粉丝页面列表、发布到流媒体等,但显然它们不适用于获取帐户信息。

以下是两种类型的访问令牌的示例。显然第一个缺少会话信息(这是第二个访问令牌的中间部分)。

116122545078207|EyWJJYqrdgQgV1bfueck320z7MM。
116122545078207|2.1vGZASUSFMHeMVgQ_9P60Q__.3600.1272535200-500880518|EyWJJYqrdgQgV1bfueck320z7MM。

Facebook provides different access tokens, some are shorter and some are longer. Without realizing the difference, I had used the shorter ones, created as type='client_cred'. These work fine for retrieving friends lists, lists of fan pages, publishing to stream etc. but apparently they do not work for getting accounts information.

Here is an example of both types of access tokens. Apparently the first one lacks session information (which is the middle part of the second access token).

116122545078207|EyWJJYqrdgQgV1bfueck320z7MM.
116122545078207|2.1vGZASUSFMHeMVgQ_9P60Q__.3600.1272535200-500880518|EyWJJYqrdgQgV1bfueck320z7MM.

随梦而飞# 2024-11-10 18:59:33

如果您的访问令牌错误,facebook 会返回以下内容:

{
   "error": {
      "type": "OAuthException",
      "message": "Error validating access token."
   }
}

似乎该令牌未传递给图形 api。根据您用来传递令牌的 SDK,可能会出现不同的错误。例如,PHP SDK 会忽略您传递的令牌并尝试从会话 cookie 中获取令牌,这会导致错误。您能澄清一下您是如何进行图形 api 调用的吗?

我已经验证,使用有效的令牌您可以获取帐户数据。您是否尝试过将其粘贴到浏览器中 https://graph.facebook.com/ (userid)/accounts?access_token=(令牌)?

If your access token is wrong facebook returns this:

{
   "error": {
      "type": "OAuthException",
      "message": "Error validating access token."
   }
}

It seems that the token is not passed to the graph api. Depending on which SDK you use to pass the token, there are different errors that can occur. The PHP SDK for example ignores the token you pass and tries to get the token from the session cookie, which causes errors. Could you clarify how are you making the graph api calls?

I have verified that with a valid token you can get the accounts data. Have you tried pasting this into your browser https://graph.facebook.com/(userid)/accounts?access_token=(token)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文