简体   繁体   English

使用 FB API 从 Facebook 页面获取帖子

[英]Fetch posts from Facebook page using FB API

Up until this summer, I had a website (not my website) which was fetching it's responding fb page posts and was displaying it on a page.直到今年夏天,我有一个网站(不是我的网站),它正在获取它的响应 fb 页面帖子并将其显示在页面上。

I was doing it using the app-token, which now doesn't work since it now requires Page Public Content Access to get those data, which in turn requires it to be registered as an app, which is beyond the scope of this.我正在使用 app-token 进行操作,现在它不起作用,因为它现在需要Page Public Content Access才能获取这些数据,这反过来又需要将其注册为应用程序,这超出了 scope 的范围。

I tried creating a non-expiring user-access token, but they seem to expire after 3 months, no matter the "trick" I tried using.我尝试创建一个不会过期的用户访问令牌,但无论我尝试使用什么“技巧”,它们似乎都会在 3 个月后过期。

Is there any suggestion of how I can get over it?有什么建议可以让我克服它吗?

Maybe an automated api call that would refresh the token with no user interaction?也许一个自动的 api 调用会在没有用户交互的情况下刷新令牌?

You can either use a Page Token (NOT a User Token) for the Page if you manage it - but it will expire.如果您管理页面,您可以使用页面令牌(不是用户令牌) - 但它会过期。 There is no way around that.没有办法解决这个问题。 OR you apply for Page Public Content Access so you can use an App Token.或者您申请页面公共内容访问,以便您可以使用应用程序令牌。

Auto-refreshing would make the whole point of expiring Tokens pointless, you need user interaction for that.自动刷新将使令牌过期的整个意义变得毫无意义,您需要用户交互。

So, I did it!所以,我做到了!

Now the how: I did it with the manage_pages access, not with Page Public Content .现在是如何做到的:我使用manage_pages访问,而不是使用Page Public Content I went back and forth a total of 5 times to get this to pass and a bit over a week.我一共来回 5 次才让这个通过了一个多星期。

First of all Page Public Content is only allowed by Facebook when you want to analyze data from other pages as well, so you better not mess with it.首先,当您还想分析来自其他页面的数据时,仅 Facebook 允许Page Public Content ,因此您最好不要乱用它。

What I had to do to get the request approved is specify on your application for requesting the access that there is no login, provide a copy of your code on the description and I also included a url where it was working with a user generated token through javascript, so they could review the code through a web debugger.为了使请求获得批准,我必须做的是在您的应用程序中指定请求没有登录的访问权限,在描述中提供您的代码副本,并且我还包括一个 url,它正在使用用户生成的令牌通过javascript,因此他们可以通过 web 调试器查看代码。

After that you get a manage_pages token which you can use to fetch your pages posts之后,您将获得一个 manage_pages 令牌,您可以使用它来获取您的页面帖子

I really hope some of those things were an overkill, but, like I said, I had to submit a review a total of 5 times, so on the last try I went all in...我真的希望其中一些事情有点矫枉过正,但是,就像我说的那样,我总共必须提交 5 次评论,所以在最后一次尝试中我全力以赴......

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

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