0

I am using the code below but its not giving any output. I want to get all the page post ID & all the comments under the given page post ID for a Facebook page I own. After I add the App ID, secret ID, Access Token, Page ID in the code below, I don't get any output.

<?php


include 'vendor/autoload.php';

use FacebookAds\Object\Values\InsightsLevels;
use FacebookAds\Api;
use FacebookAds\Object\AdUser;
use Facebook\FacebookRequestException;
use FacebookAds\Object\Values\InsightsPresets;
use Facebook\FacebookSession;
use Facebook\GraphUser;

$app_id = 'XX';
$app_secret = 'XXX';
$access_token = 'XXXX';

Api::init($app_id, $app_secret, $access_token);

$api = Api::instance();

use FacebookAds\Object\AdAccount;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Fields\CampaignFields;
use FacebookAds\Object\Fields\InsightsFields;
use Facebook\FacebookRequest;
use FacebookAds\Object\campaign;
use FacebookAds\Object\Fields\AdAccountFields;

$request = new FacebookRequest(
  $session,
  'GET',
  '/Page ID/feed',
  array(
    'fields' => 'object_id,comments'
  )
);

$response = $request->execute();
$graphObject = $response->getGraphObject();

/* handle the result */

echo  print_r( $graphObject, 1 );

}

Amit
  • 65
  • 8
  • Your request has nothing to do with the Ads API, so remove all that FacebookAds stuff. If all you are getting is a “blank page”, then please go check http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php – CBroe Jul 29 '16 at 08:24
  • I am getting Undefined variable: session error – Amit Jul 29 '16 at 08:32
  • Well you are not defining a `$session` anywhere, so that is only to be expected. // This looks like code written for the PHP SDK v4 - in v5, there is no FacebookSession class any more. Go check the documentation for FacebookRequest and see what parameters it expects in v5. – CBroe Jul 29 '16 at 08:35

0 Answers0