ajax Facebook graphApi oAuth - 如何获取访问令牌?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16054033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Facebook graphApi oAuth - how to get access token?
提问by SimonRabbit
I'm trying to get wall posts from a certain user using the JavaScript Facebook SDK. When I use the graph API Explorer, it works fine; but when I try the same thing on my website, I get the following error:
我正在尝试使用 JavaScript Facebook SDK 从某个用户获取墙贴。当我使用图形 API Explorer 时,它工作正常;但是当我在我的网站上尝试同样的事情时,我收到以下错误:
code: 104
message: "An access token is required to request this resource."
type: "OAuthException"
Where can I find my access token, so that I can show my company's Facebook page stream on my website?
我在哪里可以找到我的访问令牌,以便我可以在我的网站上显示我公司的 Facebook 页面流?
回答by ThePCWizard
Yes, you need an Access Token to fetch posts made by a Facebook Page. As the page posts are public, any access token will work. You should use an app access token as it never expires.
是的,您需要一个访问令牌来获取 Facebook 主页发布的帖子。由于页面帖子是公开的,因此任何访问令牌都可以使用。您应该使用应用程序访问令牌never expires。
- Visit https://developers.facebook.com/appsand create a new app
- Fill in the desired App Name and Namespace
- In the section 'Select how your app integrates with Facebook' choose 'Website with Facebook Login'
- Enter your website URL in the 'Site URL' field. Remember to add a trailing '/'
- Visit hereto get your
App Token.
- 访问https://developers.facebook.com/apps并创建一个新应用
- 填写所需的应用程序名称和命名空间
- 在“选择您的应用与 Facebook 集成的方式”部分中,选择“使用 Facebook 登录的网站”
- 在“站点 URL”字段中输入您的网站 URL。记得添加尾随'/'
- 访问此处获取您的
App Token.
Make calls to the graph API to fetch page posts
调用图形 API 以获取页面帖子
https://graph.facebook.com/pageID/feed?access_token=your_token

