3

I'm using facebook PHP SDK and GRAPH API to get all the posts of a page (which is I am an admin and It is a public page). I'm stuck by this instruction

$fbApp = new Facebook\FacebookApp('{app-id}', '{app-secret}');
$request = new Facebook\FacebookRequest($fbApp, '{access-token}', 'GET',   '/me');
$fb = new Facebook\Facebook(/* . . . */);
$request = $fb->request('GET', '/me');
try {
   $response = $fbApp->getClient()->sendRequest($request);
} 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 'User name: ' . $graphNode['name'];

instructions from here https://developers.facebook.com/docs/php/FacebookRequest/5.0.0#overview

it returns an error Call to undefined method Facebook\FacebookApp::getClient()

notice I'm usicng FacebookApp for getclient function so my question is how do I use facebookapp instead of facebook? to send a request to GRAPH and get a response.

also,

$request = new FacebookRequest(
  $session,
  'GET',
  '/myfbpage/posts'
);

$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

was recommended to me to be the code for PHP SDK got this from: https://developers.facebook.com/tools/explorer/

I also don't see a method execute(); in Facebookrequest is facebook documentation wrong or am I using the wrong PHP SDK?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.