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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:40:26+00:00 2026-06-17T09:40:26+00:00

I’m trying to set my WP site up so that when I publish a

  • 0

I’m trying to set my WP site up so that when I publish a post, it is sent to a Facebook Page. Unfortunatly I cannot get this to work. The code below is being included, but just seems to be doing nothing (presumably FB is sending back an error, but WP is not displaying it).

When I try to visit the feed for the Page I wish to post on (below), I’m told that I do not have the correct permissions (also below)

https://graph.facebook.com/163797013684290/feed

/** The error I recieve when visiting the above page */
{
   "error": {
      "message": "An access token is required to request this resource.",
      "type": "OAuthException",
      "code": 104
   }
}

I’ve so far completed these setps –

  1. Visit to the Graph API Explorer
  2. Select the App that I wish to post to my Page from the dropdown menu
  3. Clicked ‘Get Access Token’
  4. Selected the ‘manage_pages’ permission
  5. Re-signed in, granting permission for the App to access my Pages
  6. Created the followin script, incorporating the Access Token that has been generated.

Please can someone help, as I have no idea where to go from here. Thanks.


class Publish_To_Facebook{

    /**
     * The ID of the Page to edit
     *
     * @var string
     * @access private
     */
    private $page_id = '163797013684290';   

    /**
     * The Page access token given to the application set up to post to the Page
     *
     * @var string
     * @access private
     */
    private $page_access_token = 'my_access_token'; 

    /**
     * The back-end service for Page's wall
     *
     * @var string
     * @access private
     */
    private $post_url = '';

    /**
     * Constructor
     */
    public function __constructor(){

        $this->post_url = 'https://graph.facebook.com/'.$this->page_id.'/feed';

    }

    /**
     * Manages the POST message to post an update on a page wall
     * 
     * @param array $data
     * @return string the back-end response
     */
    public function message($data){

        /** Grab the $page_access_token */
        $data['access_token'] = $this->page_access_token;

        /** Initiate CURL */
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $this->post_url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        /** Execute and close CURL */
        $return = curl_exec($ch);
        curl_close($ch);

        return $return;

    }
}

$to_post = array(
    'message'     => 'The status header', 
    'link'        => 'http://theurltopoint.to', 
    'picture'     => 'http://thepicturetoinclude.jpg',
    'name'        => 'Name of the picture, shown just above it', 
    'description' => 'Full description explaining whether the header or the picture'
);
$facebook = new Publish_To_Facebook();
$facebook->message($to_post);
  • 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-17T09:40:27+00:00Added an answer on June 17, 2026 at 9:40 am

    I think you should look at this page to fix it. It describes the full process.

    Login as a Page

    Here is some info from the documentation regarding the Page access token:

    Page Access Tokens

    To perform the following operations as a Page, and not the current user, you must use the Page’s access token, not the user access token commonly used for reading Graph API objects. This access token can be retrieved by issuing an HTTP GET to /USER_ID/accounts with the manage_pages permission. This will return a list of Pages (including application profile Pages) to which the user has administrative access, along with access_tokens for those Pages. Alternatively, you can get a page access token for a single, specific, page by issuing an HTTP GET to /PAGE_ID?fields=access_token with the manage_pages permission, as described above. Publishing to a Page also requires the publish_stream permission, unless otherwise noted.

    Source

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.