Question

I an facing an issue with the Facebook SDK POST action when posting a very basic message on my page. I have tried to solve the issue by myself using Google and StackOverflow, but I didn't manage to find a fix.

The issue is the following:

When I post a message with the SDK, I can see it on the page (and even comment on it), and in the Facebook main feed only if I am logged in as the administrator on the page. If someone else connects to Facebook and goes to the pqge, he won't see the post!

  • I am using a PHP script on my personal desktop (WAMP server).
  • The attachement is very very basic: 'message' => "Hello dear followers!"
  • The application used to post is in sandbox mode.
  • Your app detail page has not yet been submitted for review.
  • The message appears as public on the page.
  • When I post manually, the exact same message on the page and everything is found.

It's very strange that I can see the post on the page, but nobody else can. Can you help me with this issue? Also, the message is not posted in Twitter, whereas the page is linked to a Twitter account. Hereafter is the very simple piece of code associated with the problem.

$appid = *(hidden)*;
$appsecret =  *(hidden)*;
$pageId=  *(hidden)*;
$facebook = new Facebook(array('appId' => $appid,'secret' => $appsecret,'cookie' => false));
$user = $facebook->getUser();

if($user){

    try{

        $page_info = $facebook->api("/$pageId?fields=access_token");

        if (!empty($page_info['access_token'])){

            $attachment = array(

            'access_token' => $page_info['access_token'],
            'message' => "Hello dear followers!"

            );

            $status = $facebook->api("/$pageId/feed", "post", $attachment);

        }

    }

}
Was it helpful?

Solution

It sounds for me that you didn't set the privacy of posts posted by your application inside of Facebook.

See if "Only me" appears for your application posts (like in the following image).

enter image description here

Then, verify the "sandbox" mode of your application.

enter image description here

If it's set ON, set it OFF.

What is Sandbox Mode?

When testing your apps, place them into Sandbox Mode. This hides your app entirely from all users who you have not authorized in the App Dashboard to see the app, for the roles described below. Please note that when your app is in Sandbox Mode, you cannot call any API calls on behalf of users who cannot see your app.

source

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top