Get long term access token for Facebook page

北慕城南 提交于 2019-12-29 02:07:12

问题


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);

// ...

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 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.

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.

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?


回答1:


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/

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.

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).



来源:https://stackoverflow.com/questions/33025307/get-long-term-access-token-for-facebook-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!