JavaScript 中图形 api 调用的 access_token

发布于 2024-12-29 04:36:13 字数 141 浏览 1 评论 0原文

我正在尝试使用 JavaScript 将公共 Facebook 页面上的帖子和评论拉入并显示在我客户的网页上。我知道我需要一个 access_token,但问题是它经常过期。看来我需要动态获取 access_token 以避免这个问题。有谁知道如何在客户端执行此操作?

I am trying to pull in and display the wall posts and comments from a public Facebook page on my client's webpage using JavaScript. I know I need an access_token, but the problem is it expires every so often. It seems I would need to dynamically get the access_token to avoid that issue. Does anyone know of a way to do this client-side?

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

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

发布评论

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

评论(1

缱绻入梦 2025-01-05 04:36:13

简短的回答:

如果页面确实是公开的,则根本不需要访问令牌。例如,

http://graph.facebook.com/19292868552
{
   "id": "19292868552",
   "name": "Facebook Platform",
   "picture": "http://profile.ak.fbcdn.net/hprofile-ak-ash2/276791_19292868552_1958181823_s.jpg",
   "link": "http://www.facebook.com/platform",
   "likes": 3922010,
   "category": "Product/service",
   "website": "http://developers.facebook.com",
   "username": "platform",
   "founded": "2007",
   "company_overview": "Facebook Platform enables anyone to build social apps on Facebook and the web.",
   "mission": "To make the web more open and social.",
   "about": "We're building the social web. Get the latest here: developers.facebook.com ",
   "talking_about_count": 74536
}

更长的答案,如果您使用特定用户的访问令牌代表他们执行操作,您可能会考虑请求“离线访问”,以便令牌不会过期。请参阅https://developers.facebook.com/docs/reference/api/permissions/< /a> 了解有关如何请求此权限的更多信息。

Short answer:

If the page is really public, you don't need an access token at all. For instance,

http://graph.facebook.com/19292868552
{
   "id": "19292868552",
   "name": "Facebook Platform",
   "picture": "http://profile.ak.fbcdn.net/hprofile-ak-ash2/276791_19292868552_1958181823_s.jpg",
   "link": "http://www.facebook.com/platform",
   "likes": 3922010,
   "category": "Product/service",
   "website": "http://developers.facebook.com",
   "username": "platform",
   "founded": "2007",
   "company_overview": "Facebook Platform enables anyone to build social apps on Facebook and the web.",
   "mission": "To make the web more open and social.",
   "about": "We're building the social web. Get the latest here: developers.facebook.com ",
   "talking_about_count": 74536
}

Longer answer, if you are using a particular user's access token to perform actions on their behalf, you might consider asking for "offline access" so that the token won't expire. See https://developers.facebook.com/docs/reference/api/permissions/ for more information about how to ask for this permission.

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