简体   繁体   English

Facebook graphApi oAuth - 如何获取访问令牌?

[英]Facebook graphApi oAuth - how to get access token?

I'm trying to get wall posts from a certain user using the JavaScript Facebook SDK. 我正在尝试使用JavaScript Facebook SDK从某个用户获取墙上帖子。 When I use the graph API Explorer, it works fine; 当我使用图形API资源管理器时,它工作正常; 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"

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. 是的,您需要一个访问令牌来获取Facebook页面发布的帖子。 As the page posts are public, any access token will work. 由于页面帖子是公开的,任何访问令牌都可以使用。 You should use an app access token as it never expires . 您应该使用应用程序访问令牌,因为它never expires

  1. Visit https://developers.facebook.com/apps and create a new app 访问https://developers.facebook.com/apps并创建一个新应用
  2. Fill in the desired App Name and Namespace 填写所需的应用程序名称和命名空间
  3. In the section 'Select how your app integrates with Facebook' choose 'Website with Facebook Login' 在“选择您的应用与Facebook集成的方式”部分中选择“使用Facebook登录的网站”
  4. Enter your website URL in the 'Site URL' field. 在“网站网址”字段中输入您的网站网址。 Remember to add a trailing '/' 记得添加尾随'/'
  5. Visit here to get your App Token . 访问此处获取您的App Token

Make calls to the graph API to fetch page posts 调用图API来获取页面帖子

https://graph.facebook.com/pageID/feed?access_token=your_token

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM