1
votes

I need help to make a facebook app on my website permanent. The access token keeps expiring and i dont know how to get a permanent token. Im using the fb.wall from "http://www.neosmart.de/social-media/facebook-wall/"

Here is my code:

<script type="text/javascript">
        $(function () {
            $('#example1').fbWall({
                id: 'Facebookuser',
                accessToken: 'accesstokengoeshere',
                showGuestEntries: false,
                showComments: true, max: 5,
                timeConversion: 24
            });
        });
    </script>
1

1 Answers

0
votes

Instead of trying to get a permanent access token, try making a call to a function like this one each time where you have 'accesstokengoeshere':

function getAccessToken () {
    FB.getAuthResponse(function(response) {
      if (response.status == 'connected') {
        return response.authResponse.accessToken;
      } else if (response.status === 'not_authorized') {
      // if the user is not logged in to FB, prompt them to do so
      // later might want to change this so it doesn't automatically prompt you to login
      FB.login(function(response) {
        return getAccessToken();
      });
    } else {
      FB.login(function(response) {
        return getAccessToken();
      });
    }
  });
  }