Facebook Api: How to get feed from a page using PHP?

1

I'm trying to pull the posts of a page on facebook and display them on a website, what I mainly need is the photo and the caption of each post.

I'm using the following code:

<?php
require_once __DIR__ . '/inc/facebook-php-graph-sdk-5/src/Facebook/autoload.php';
require_once __DIR__ . '/inc/facebook-php-graph-sdk-5/src/Facebook/FacebookRequest.php';

/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{page-id}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
print_r($graphObject);
/* handle the result */
?>

And I'm getting the following error:

Fatal error: Class 'FacebookRequest' not found in C:\xampp\htdocs\www\site\wp-content\themes\tema\functions.php on line 7

As I'm inserting the FaacebookRequest.php and saying that the 'FacebookRequest' class not found?

I've never done this before and I'm having doubts to begin with, I'm researching and reading the documentation, and even though I'm having difficulty understanding the documentation, what's helping me the most are the questions I find in independent forums and articles.

You do not have to answer everything chewed, if you have a link where I can find the answer, I'll be immensely grateful.

UPDATE:

I continued searching and I was able to do this through the documentation of facebook itself:

<?php
require_once 'inc/facebook-php-graph-sdk-5/src/Facebook/autoload.php';

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

$response = $fb->get('/PAGE-NAME/feed', 'ACCESS-TOKEN-AQUI');

print_r($response);
?>
    
asked by anonymous 20.10.2016 / 17:57

0 answers