获取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?
由于网站不托管在Apache服务器中,因此不允许使用PHP。我正在寻求一个客户端解决方案。任何帮助将被高度赞赏。
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.
更新:根据我的研究,我认为得到一个不会在一个月内过期的令牌并且具有管理页面
权限(授予阅读页面Feed的唯一权限),需要创建包括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.
我没有任何意图让人登录,因为它是一个静态网站。是否有可能性获取一个不会在一个小时内过期并且具有阅读页面的Feed的权限的静态访问令牌,而不创建应用程序,为其添加隐私策略页面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) is explained very well in the docs:
- https://developers.facebook.com/docs/facebook-login/access-tokens
如果还不够,这里有另一个链接:
Here´s another link if that is not enough:
- http://www.devils-heaven.com/facebook-access-tokens/
正如CBroe所言,你不需要扩展令牌客户端。为了获取页面的Feed,应用程序令牌是足够好的 - 但是您不应该在客户端上公开您的App Secret。这是一个理由叫做秘密。而且我希望你不要像每个用户一样使用静态令牌。无论您使用的令牌,不要将其公开给其他用户。
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屋!