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

Sunday, February 27, 2022

[FIXED] Posts via facebook SDK on fanpage are only visible to myself?

 February 27, 2022     facebook-php-sdk, php     No comments   

Issue

I'm facing a little problem.
I want to autopost on my facebook fanpage via php.
I created an facebook app, got the secret key and the app ID and created an 60 day access-token. When I post on my fanpage via php, I can see the photo and the text and it says "public". But only I can see the post, nobody else.

I don't really know why. The app isn't public (because I'd need to add an url to privacy policy. Also user_posts, publish_pages, user_photos and manage_pages aren't properly activated, I guess. It's only a few lines of code with my access-token and stuff like that. Nothing where anyone would log in or anything like that.

Sorry if it's poorly explained.

Edit:// This is all the code I'm using to post:

require_once('src/Facebook/autoload.php');

$fb = new Facebook\Facebook([
    'app_id' => 'App-ID',
    'app_secret' => 'App-Secret',
    'default_graph_version' => 'v2.2',
]);

$data = [
    'message' => $text,
    'source' => $fb->fileToUpload('photo.png'),
];

try {
    $response = $fb->post('/me/photos', $data, 'My Access-Token');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
}

$graphNode = $response->getGraphNode();

echo 'Photo ID: ' . $graphNode['id'];

Solution

The app isn't public

That's your issue.

https://developers.facebook.com/docs/apps/managing-development-cycle

When your app is in development mode only the people that you have configured via the Roles setting (more information on this below) will have access to use the app. Any person that has not been explicitly whitelisted in a Role will not be able to see the app, nor will they see any Feed stories, Requests or other social distribution features.

Put a short privacy policy up somewhere - Github, Pastebin, whatever - and turn the app on.



Answered By - ceejayoz
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

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