Facebook graphApi oAuth - 如何获取访问令牌? [英] Facebook graphApi oAuth - how to get access token?
问题描述
我正在尝试使用JavaScript Facebook SDK从某个用户获取墙贴。当我使用图形API资源管理器,它工作正常;但是当我在我的网站上尝试相同的事情时,我收到以下错误:
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:
code: 104
message: "An access token is required to request this resource."
type: "OAuthException"
在哪里可以找到我的访问令牌,以便我可以在我的网站上显示我公司的Facebook页面流?
Where can I find my access token, so that I can show my company's Facebook page stream on my website?
推荐答案
是的,您需要一个访问令牌来获取Facebook页面。当页面帖子是公开的时,任何访问令牌都可以工作。您应该使用应用访问令牌,因为永不过期
。
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
.
- 访问 https://developers.facebook.com/apps 并创建一个新的应用程序
- 填写所需的应用程序名称和命名空间
- 在选择您的应用程序如何与Facebook集成部分选择使用Facebook登录的网站
- 在网站URL字段中输入您的网站网址。记住添加一个尾随'/'
- 访问这里获取您的
应用程序令牌
。
- Visit https://developers.facebook.com/apps and 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 here to get your
App Token
.
调用图形API fetch page posts
Make calls to the graph API to fetch page posts
https://graph.facebook.com/pageID/feed?access_token=your_token
这篇关于Facebook graphApi oAuth - 如何获取访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!