PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 10, 2022

[FIXED] facebook post on page wall - PHP SDK

 January 10, 2022     facebook, facebook-graph-api, facebook-php-sdk, php     No comments   

Issue

I'm trying to create a script that post on a facebook page (as an administrator) a status. This is the script i'm using:

try {
    $access_token = (new FacebookRequest( $session, 'GET', '/' . $pageID,  array( 'fields' => 'access_token' ) ))
        ->execute()->getGraphObject()->asArray();

    $access_token = $access_token['access_token'];
    
    $page_post = (new FacebookRequest( $session, 'POST', '/'. $pageID .'/feed', array(
        'access_token' => $access_token,
        'message' => $message,
      ) ))->execute()->getGraphObject()->asArray();
} catch (FacebookRequestException $e) {
    echo 'ERROR! ' . __LINE__ . $e->getMessage();   
} catch (Exception $e) {
    echo 'ERROR! ' . __LINE__ . $e->getMessage();
}

The script does work, and I see the post on facebook (ignore language): enter image description here

The problem is that I'm the only one who can see this post. When other users enter the page, they can't see the post, and if I give them the post's url, it says that it doesn't exist.


Solution

You need to make your app public, on top of Status&Review tab in app dashboard.

As long as an app is in development mode, everything it “creates” on Facebook is only visible to app admins/developers/testers.

(This does not require to submit your app for review, since you will only be using it yourself. Only if you wanted to ask other users for permissions as well, you’d need to submit those for review.)



Answered By - CBroe
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing