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 6753739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:11:52+00:00 2026-05-26T13:11:52+00:00

I’ve made a simple app for the purpose of posting to a Facebook Page

  • 0

I’ve made a simple app for the purpose of posting to a Facebook Page using PHP scripts from my personal web site.

After much trial and error, it seems to work just fine. I can log in to my app via my web site, post something, and it returns to my web site. So all is good.

The one oddity is that despite everything working, I am getting this error in my logs:

OAuthException: Error validating access token: The session is invalid
because the user logged out.

I’ve Googled the error, and from what I’ve seen, most people are experiencing time outs or being unexpectedly logged out. Solutions range within terms of how to maintain a logged in session.

However, I think my case is different from other questions I’ve seen because, despite the error, I seem to remain logged in. I can post to my Page wall as many times as I want.

The error does not seem to be generated every time I post to the wall. It seems to come up one out of every three or four, but it is not consistent, and I have not been able to determine a pattern.

Since everything is working, I could just ignore the error message, but that seems to me to be bad practise. I don’t want anything sneaking up to bite me later.

Any help or advice would be much appreciated.


The code that drives the Facebook interaction is integrated with my CMS, so some parts of it are spread around, and/or might be obscure because of the parts I had to customize. However, I believe this function has the meat of the PHP interaction. Please let me know if this is sufficient to help determine the source of the problem:

private function executeFacebookPost()
{
    // Facebook posts are limited to 420 characters. Links and pictures
    // are separate.
    $bodyOption = $this->mention->getOption(Action::$BODY);
    if (count($bodyOption) == 0)
    {
        $fbPost = '';
    }
    else
    {
        $fbPost = $bodyOption[1];
    }

    $linkOption = $this->mention->getOption(Action::$LINK_TO);
    if (count($linkOption) == 0)
    {
        $link = '';
    }
    else
    {
        $link = $linkOption[1];
    }
    // Use require_once() and not require() because you might be doing
    // some facebook action elsewhere, and this script will die a sad
    // death if it's asked to require more than once.
    require_once('+facebook/facebook.php');

    // Create our Application instance
    $facebook = new Facebook(array(
                'appId' => Site::getFacebookAppID(),
                'secret' => Site::getFacebookSecret(),
            ));
    $fbUser = $facebook->getUser();
    if ($fbUser)
    {
        try
        {
            $page_id = Site::getFacebookPage();
            $page_info = $facebook->api("/$page_id?fields=access_token");
            if (!empty($page_info['access_token']))
            {
                $args = array(
                    'access_token' => $page_info['access_token'],
                    'message' => $fbPost,
                    'link' => $link,
                        //'description' => "aaaaaaaasdfsfsdf",
                        //'picture' => "http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/fte/army_troop.png",
                );
                $post_id = $facebook->api("/$page_id/feed", "post", $args);
            }
        }
        catch (FacebookApiException $e)
        {
            error_log($e, 1, 'ebisudave@gmail.com');
        }
    }
}
  • 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-05-26T13:11:53+00:00Added an answer on May 26, 2026 at 1:11 pm

    When you get your access_token, request offline_access and then your token won’t expire.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm making a simple page using Google Maps API 3. My first. One marker
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am using Paperclip to handle profile photo uploads in my app. They upload
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am using jsonparser to parse data and images obtained from json response. When
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.