Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:04:50+00:00 2026-06-12T13:04:50+00:00

I am trying to create a non-expiring page token that I can use on

  • 0

I am trying to create a non-expiring page token that I can use on my site to make posts on my Facebook page. According to scenario 5 in this document I should be able to do this:

https://developers.facebook.com/roadmap/offline-access-removal/

My problem is that when I generate the page tokens, they expire in 1 hour.

What I am doing is using this code to display my user access token when I login. I think this is the same token provided by graph api explorer, but I am unsure.

require '../src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'app_id',
  'secret' => 'app_secret',
));   

$user = $facebook->getUser();

if ($user) {
  try {
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }   
}     

if ($user) {
  $logoutUrl = $facebook->getLogoutUrl( array(

                'scope'         => 'read_stream,publish_stream,publish_actions,manage_pages,email,user_checkins',
                ));
} else {
  $loginUrl = $facebook->getLoginUrl();
}
echo $loginUrl;

$me = $facebook->api('/me');

?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
    <title>php-sdk</title>
  </head>
  <body>
    <h1>php-sdk</h1>

    <?php if ($user): ?>
      <a href="<?php echo $logoutUrl; ?>">Logout</a>
    <?php else: ?>
      <div>
        Login using OAuth 2.0 handled by the PHP SDK:
        <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
      </div>
    <?php endif ?>

    <h3>PHP Session</h3>
    <pre><?php print_r($_SESSION); ?></pre>

    <?php if ($user): ?>
      <h3>You</h3>
      <img src="https://graph.facebook.com/<?php echo $user; ?>/picture">

      <h3>Your User Object (/me)</h3>
      <pre><?php print_r($user_profile); ?></pre>
    <?php else: ?>
      <strong><em>You are not Connected.</em></strong>
    <?php endif ?>

  </body>
</html>

I then use that token in this graph api command:

https://graph.facebook.com/me/accounts?access_token=<access_token>

This gives me a list of all my pages and apps and their respective page/app tokens.

I then take the page token I want to use and check with the Facebook Access Token Debugger and it shows it has an expiration of 1 hour. So I use the following command to try and exchange it for a 60 day token as described in the first URL i posted:

https://graph.facebook.com/oauth/access_token?client_id=client_id&client_secret=client_secret&grant_type=fb_exchange_token&fb_exchange_token=access_token

The command just gives me the error: “message”: “An unknown error has occurred.”,”type”: “OAuthException”, “code”: 1.

I then thought maybe because my user access token is not long lived, it wont generate a long lived page token. So I used my user token with the same command to extend it and it just returns the same token back with the expiration not extended.

Can anyone offer some insight as to what I am doing wrong and how I can create this non-expiring page token?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:04:51+00:00Added an answer on June 12, 2026 at 1:04 pm

    Read the instructions again carefully – based on your description you’re:

    • Getting a short user token
    • Getting a short page token from /me/accounts
    • Attempting to extend the short page token

    What you should be doing is:

    • Getting a short user token (if client side auth)
    • Exchanging that for a long user token (or you’ll already have a long user token if you used the server side oauth flow)
    • Using the long user token to retrieve the (long) page access token
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I'm trying to create a JAR that I can put on a non development
I'm trying to create a function that will check to make sure all the
I'm trying to use the Facebook C# SDK to publish posts to the wall
I am trying to create a procedure that has a user input a non-empty
I'm trying to create a CSV file using php. How can I print non
I am trying to create a program that puts identical non-overlapping particles of diameter
I am trying to create an application compatible with both retina and non-retina displays.
I am trying to create a singleton which has a non-empty constructor and to
Trying to create a facebook app just to learn and coming across a strange

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.