3
votes

My each user generating a long lived (60 days) access token from my site using graph api.But the problem is when it expires after 60 days, user have to generate it again by coming to my website.Sometimes they forget about token expiration and facebook page feed shows error in their websites.

in another post i mentioned about how i generate token long ago here- http://stackoverflow.com/questions/16962486/extending-valid-expired-60-days-access-token-without-user-interaction

Now how do i automatically refresh the long-lived token from code in their site so that user don't need to get token 2nd time by coming to my token generation website page.

in section Generating Long-Lived User Tokens from Server-Side Long-Lived Tokens of facebook help page - https://developers.facebook.com/docs/facebook-login/access-tokens I see ways to refresh token, but is it the way i want that there will be no user interaction while generating token?? I need example codes as it's hard to understand.

1
what about a bit of JS code they load from your site that'd do an ajax call back to your site, which you could then use to send back the relevant updated cookie? It wouldn't even have to do an ajax call. it could be a simple <script src="yoursite.com/renewtoken.php?id=..."></script> type thing.Marc B
Not getting - "what about a bit of JS code they load from your site"dev-m
Simple answer- not possible!Sahil Mittal
Does the section i mentioned in facebook help site reveals something? Waiting for reply from facebook employee.dev-m

1 Answers

4
votes

I think so. Try to check this out here:

https://www.sammyk.me/access-token-handling-best-practices-in-facebook-php-sdk-v4

Look at "Best Practices for maintaining long lived access tokens over time". Guess you may find the answer you need.