帮助了解如何将 FB Graph API 集成到我的应用程序中

发布于 2024-11-05 08:42:37 字数 865 浏览 1 评论 0原文

我正在努力让我的应用程序能够访问 FB Graph API 来查找用户数据。我想以一种以应用程序为中心的方式来执行此操作,这意味着它不是基于登录到我的应用程序的用户。这是应用程序和应用程序之间的关系。 FB 图形 API。

我的理解是我可以使用应用程序访问令牌来做到这一点,对吗?

如果我在这里使用我的应用程序访问令牌: https://graph.facebook.com /[电子邮件受保护] &type=user&access_token=208131059208382|xFN8da1tIDxuuMp8hoRtGs3l0aM

我收到错误:

{
   "error": {
      "type": "OAuthException",
      "message": "An access token is required to request this resource."
   }
}

这是为什么?

我可以使用我的个人 FB 帐户来访问 API 以实现应用程序的目的吗?

当用户 oAuth 进入应用程序时,访问令牌会持续多长时间?我可以在我的应用程序中进行硬编码,以便我可以使用 FB 图形 API 吗?

谢谢

I'm working to enable my app to hit the FB Graph API to look up data on a user. I want to do this in a way that is app focused meaning it isn't based on a user signed into my app. It's a relationship between the app & the FB Graph API.

My understanding is I can do that with the APPLICATION ACCESS TOKEN is that right?

If I use my app access token here:
https://graph.facebook.com/[email protected]&type=user&access_token=208131059208382|xFN8da1tIDxuuMp8hoRtGs3l0aM

I get an error:

{
   "error": {
      "type": "OAuthException",
      "message": "An access token is required to request this resource."
   }
}

Why is that?

Can I use my personal FB account to hit the API for the purposes of the app?

When a user oAuth's in to an app, how long does the access token last? Is it something I can hard code in my app so I can hit the FB graph api?

Thanks

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

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

发布评论

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

评论(3

江湖彼岸 2024-11-12 08:42:38

对于 Facebook 上的很多事情,您必须拥有用户提供的有效会话访问令牌。这意味着,您从用户那里获得的访问令牌必须用于访问资源。当从图表中提取有关用户的数据时尤其如此。当用户加载您的应用程序时,FB 为您提供的访问令牌通常会持续一个小时(如果我没记错的话)。不过,FB 提供的会话对象会告诉您令牌的过期时间。

如果您需要以离线方式访问用户的数据,您可以向用户请求offline_access 扩展权限。这样做会让 Facebook 为您提供一个无限期的访问令牌,该令牌永远不会过期(除非用户更改密码)。这样您就可以随时代表用户查询图表。

如果您执行标准搜索或页面搜索等,则搜索功能不需要访问令牌。但在搜索用户时,它确实需要有效的访问令牌。我认为这是为了防止人们使用机器人进行搜索和抓取公共用户数据。

For a lot of things on Facebook, you have to have a valid session access token from the user. What this means is, the access token you get from a user must be used to access a resource. This is especially true when pulling data about the user out of the graph. The access token that FB gives you when the user loads your application typically lasts for an hour (if I recall correctly). The session object FB gives you tells you the expire time on the token, though.

If you need to access the data for a user in an offline manner, you could ask the user for the offline_access extended permission. Doing this makes Facebook give you an indefinite access token, which doesn't ever expire (unless the user changes their password). That allows you to query the graph on the user's behalf whenever you feel like doing it.

The search feature doesn't require an access token if you're performing a standard search, or a page search, etc. But it does require a valid access token when you're searching for users. I assume this is to keep people from hammering the search and crawling public user data with a bot.

叫思念不要吵 2024-11-12 08:42:38

看看 https://github.com/michaelbaldry/fb_graph_canvas - 这是一个准系统的画布应用程序,您可以使用它可以在本地测试。它使用 fb_graph 并且尽可能简单。

take a look at https://github.com/michaelbaldry/fb_graph_canvas - It's a barebones canvas application that you can test locally. It uses fb_graph and is about as simple as can.

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