获取 Facebook 页面的长期访问令牌 [英] Get long term access token for Facebook page
问题描述
我正在使用 Jquery Facebook Wall 来检索 Facebook 页面的最新状态并在网站上展示.
I'm using Jquery Facebook Wall to retrieve the latest status of a Facebook page and show it in a website.
(function($) {
$(document).ready(function(){
$('#facebook_wall').facebook_wall({
id: '560124337XXXXX',
access_token: 'CXGXhXZA7Wg2XXDcTi7WmX1wp71u5fNXXa9XXX3LmXXx',
limit: 1
});
});
})(jQuery);
// ...
当我使用 FB Graph API Explorer 获取访问令牌
在页面中,我得到了一个仅在 60 分钟内过期.有没有办法获得长时间的访问令牌
?或者每次用户连接到网站页面时生成一个新的?
When I use FB Graph API Explorer to get the access token
of the page, I get one that expire in only 60 minutes. Is there a way to get a long duration access token
? Or to generate a new one each time a user connect to the website page?
不允许使用 PHP,因为该网站未托管在 Apache 服务器中.我正在寻求客户端解决方案.任何帮助将不胜感激.
PHP is not allowed since the website isn't hosted in an Apache server. I'm seeking a client-side solution. Any help will be highly appreciated.
更新:根据我的研究,我假设获得一个不会在一个月内过期并且具有 Manage Pages
权限(授予的唯一权限)的令牌阅读页面提要),需要创建一个包含Facebook 登录"的 Facebook 应用,然后等待审核流程"批准.
Update : According to my researches, I assume that getting a token that doesn't expire in one month and that have Manage Pages
permission (the only permission that grant reading a page feeds), require the creation of a Facebook app that include "Facebook login" and then waiting for the "Review Process" approval.
我无意让人们登录,因为它是一个静态网站.是否有可能性获得一个静态访问令牌,该令牌不会在一个小时内过期并且具有阅读页面提要"的权限,而无需创建应用程序,为其添加隐私政策页面 URL,等待审核过程,让人们登录......而且不诉诸服务器端选项?
I don't have any intention to make people login since it's a static website. Is there a possibility to get a static access token that doesn't expire in an hour and that have the permission of "reading page's feed", without creating the app, adding a privacy policy page URL for it, waiting for the review process, making people login... And without resorting to server-side options?
推荐答案
How to generate different Tokens (App Token, User Token, Page Token, Extended User Token, Extended Page Token) 在文档中有很好的解释:
How to generate different Tokens (App Token, User Token, Page Token, Extended User Token, Extended Page Token) is explained very well in the docs:
>
- https://developers.facebook.com/docs/facebook-login/访问令牌
如果这还不够,这里还有另一个链接:
Here´s another link if that is not enough:
正如 CBroe 评论的那样,您不需要扩展令牌客户端.要获取页面的提要,应用程序令牌就足够了 - 但你永远不应该在客户端公开你的应用程序秘密.它被称为秘密是有原因的.我希望你不要试图为每个用户使用这样的静态令牌.无论您使用什么令牌,都不要将其暴露给任何其他用户.
As CBroe commented, you don´t need extended Tokens client-side. For getting the feed of a Page, an App Token is good enough - but you should NEVER expose your App Secret on the client. It is called Secret for a reason. And i hope you´re not trying to use static Token like that for every user. Whatever Token you are using, don´t expose it to any other users.
您也可以只使用页面插件:https://developers.facebook.com/docs/plugins/page-plugin(再次感谢 CBroe 指出额外的解决方案).
You could also just use the Page Plugin: https://developers.facebook.com/docs/plugins/page-plugin (again, thanx to CBroe for pointing out that additional solution).
这篇关于获取 Facebook 页面的长期访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!