Navbar

My Blog List

Friday, August 17, 2018

Structure of Facebook PHP SDK in PHP

<?php
require_once ('vendor/autoload.php');

$fb = new Facebook\Facebook([
'app_id' => '************',
'app_secret' => '************************',
'default_graph_version' => 'v2.3',
]);

$pageAccessToken = '************************************';


try
{
$response = $fb->post('/me/feed', $pageAccessToken);
}
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 'ID:'.$graphNode['id'];

?>

2 comments:

  1. How to edit Graph returned an error: (#200) If posting to a group, requires app being installed in the group, and \ either publish_to_groups permission with user token, or both manage_pages \ and publish_pages permission with page token; If posting to a page, \ requires both manage_pages and publish_pages as an admin with \ sufficient administrative permission

    ReplyDelete
  2. composer require facebook/graph-sdk in your working directory then all files are coming

    ReplyDelete