使用访问令牌获取数据
我想获取特定用户的提要/帖子/状态数据。 但发现需要有access token。 我担心的是,我们是否需要为每个用户提供单独的访问令牌来获取他们的信息,或者仅使用单个访问令牌就可以?
I want to fetch feed/post/statuses data for a particular user.
But found that it is necessary to have an access token.
My concern is , do we need to have a separate access token for every user to fetch their information or merely with a single access token it is possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
访问令牌用于验证发出调用的用户是否已通过验证并具有执行该操作的正确权限。每个用户对于每个应用程序都有自己的访问令牌。正如上面的评论所述,访问令牌会在一段时间后过期,因此当用户重新登录到您的应用程序时,您必须重新请求它们。
还有“长期”访问令牌,可以通过请求
offline_access
权限来检索。在这种情况下,访问令牌的有效期(我认为)为 30 天,或者直到用户更改他/她的 facebook 密码为止。您需要的有关访问令牌的所有信息都可以在 https://developers.facebook.com/docs/ 找到身份验证/
The access token is used to verify that the user making the call is verified and has the correct permissions to perform that action. Every user has his/her own access token for each application. As the comments say above, access tokens expire after a while, so you have to re-request them when the user logs back into your application.
There is also "long-term" access tokens that can be retrieved by requesting the
offline_access
permission. In this case the access token is valid for (i think) 30 days or until the user changes his/her facebook password.All the information you need about access tokens can be found at https://developers.facebook.com/docs/authentication/
Facebook Graph API 访问令牌允许您执行以特定用户身份运行且具有一组特定权限 (https://developers.facebook.com/docs/reference/api/permissions/) 的 Facebook 应用程序被允许执行的操作做。其他 Facebook 对象(例如用户)上的某些数据可以通过另一个用户的访问令牌获得,特别是如果他们是访问令牌中的用户的“朋友”。
例如,假设访问令牌指定用户 A 和权限“friends_birthday”。如果 (1) 用户 B 是用户 A 的朋友,并且 (2) 用户 B 允许他/她的朋友查看他/她的生日,那么您应该能够查询用户 B 的生日。
我不知道你的完整场景,但如果你真的只是获取数据,你可能会发现使用 https:// facebookpsmodule.codeplex.com 而不是编写您自己的 Facebook 应用程序。
An Facebook Graph API access token allows you to do what a Facebook application running as a particular user, with a particular set of permissions (https://developers.facebook.com/docs/reference/api/permissions/), is permitted to do. Some data on other Facebook objects (such as users) may be available with the access token of another user, especially if they are a "friend" of the user in the access token.
For example, suppose the access token specifies User A and permission "friends_birthday". You should be able to query the birthday of user B if (1) user B is a friend of user A, and (2) user B permits his/her friends to see his/her birthday.
I don't know your full scenario, but if you are really just fetching data, you may find it easier to use https://facebookpsmodule.codeplex.com rather than writing your own Facebook application.