Post data into facebook page using php without facebook login

I’m using the following code-

require_once __DIR__ . ‘/assets/php-graph-sdk/src/Facebook/autoload.php’;
$appId = ”; //Facebook App ID
$appSecret = ”; //Facebook App Secret
$redirectURL = ”; //Callback URL
$fbPermissions = array(‘publish_actions’); //Facebook permission

$access_token = “”;//Facebook Page Access Token
$page_id = “”; //Facebook Page ID

$url = “https://graph.facebook.com/$page_id/feed”;

$data = array(
‘access_token’ => $access_token,
‘message’ => “Text2”,
‘link’ => “www.google.fi”,
‘name’ => “my name”, // Title for link
‘description’ => “description” // Description for link
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result = curl_exec($ch);
curl_close ($ch);
print_r ($result);

But the above code show the error:

{“error”:{“message”:”(#200) If posting to a group, requires app being installed in the group, and n either publish_to_groups permission with user token, or both manage_pages n and publish_pages permission with page token; If posting to a page, n requires both manage_pages and publish_pages as an admin with n sufficient administrative permission”,”type”:”OAuthException”,”code”:200,”fbtrace_id”:”Az1ozzoCVIU”}}

Thanks in advance

Read more here:: Post data into facebook page using php without facebook login

Leave a Reply

Your email address will not be published. Required fields are marked *