简体   繁体   中英

Get long term access token for Facebook page

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?

How to generate different Tokens (App Token, User Token, Page Token, Extended User Token, Extended Page Token) is explained very well in the docs:

Here´s another link if that is not enough:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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