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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:20:11+00:00 2026-05-28T00:20:11+00:00

I have a problem with adding a post on a page as a page.

  • 0

I have a problem with adding a post on a page as a page.
I use the following code:

$app_id = "xxx";
$app_secret = "xxx";
$my_url = base_url().'admin/facebook/';

if(isset($_GET["code"])) {
    $code = $_GET["code"];
} else {
    $code = '';
}
if(empty($code)) {
 $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
 $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
   . $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=manage_pages,publish_stream,offline_access&state="
   . $_SESSION['state'];

 echo("<script> top.location.href='" . $dialog_url . "'</script>");
}

if($_GET['state'] == $_GET['state']) {

 $token_url = "https://graph.facebook.com/oauth/access_token?"
   . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
   . "&client_secret=" . $app_secret . "&code=" . $code;

 $response = @file_get_contents($token_url);
 $params = null;
 parse_str($response, $params);

 $graph_url = "https://graph.facebook.com/me?access_token=".$params['access_token'];

 $user = json_decode(file_get_contents($graph_url));
 echo("Hello " . $user->name);

    $pageID = '212154388861617';


    // post to wall (feed is wall post, just update to whatever you want to publish to)
    try {
        //153406078098666
        $publishStream = $this->fb_ignited->api("212154388861617/feed", 'post', array(
            'message' => "Test message",
            'access_token'    => $params['access_token']
            )
        );
    } catch (FacebookApiException $e) {
        die($e);
    }
}
else {
 echo("The state does not match. You may be a victim of CSRF.");
}

The post is correctly being added on my page but the post is being added as my user-account and not as my page-account.
How can i post as a page?
Or isn’t this possible?

Solution: I added this piece of code

$result = $this->fb_ignited->api("/me/accounts",  array('access_token'    => $params['access_token']));
         foreach($result["data"] as $page) {
            if($page["id"] == $pageID) {
                $page_access_token = $page["access_token"];
                break;
            }
         }
  • 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-28T00:20:12+00:00Added an answer on May 28, 2026 at 12:20 am

    You’re using user’s access_token while you need to use page access_token.

    This can be obtained via Graph API from accounts connection of user once user granted manage_pages permission to your application

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

Sidebar

Related Questions

I have a problem adding ADO.Net Entity Data Model to my existing project, or
I have a problem adding entities to a collection. public void SaveNotificationUsergroups(int bookingobjectID, int[]
I have some problem with my .htaccess file. Here I am adding my problem.
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have an IFrame Facebook application that uses Facebook C# SDK. I also use
My problem is I have a form in an .html page which activates a
I have a similar problem with this ( https://wordpress.stackexchange.com/questions/9593/custom-post-type-archive-with-pagination ) and can't really figure
In my view I currently have the following code: <%= Html.Hidden(Cart.CartID, Model.Cart.CartID) %> When
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names

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.