0

So i started learning facebook sdk and i wanted to get attening_count/list from my event page as an array, but i'm unable to get it working. It only displays me id, name etc.

if (isset($_SESSION['access_tok'])) {
echo '<a href="out.php">Out!</a><br>';
try {
$response = $fb->get('me/accounts?fields=', $_SESSION['access_tok']);
$page = $response->getGraphEdge();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}

foreach($page as $pages)
{
$name = $pages['name'];
$cc = $pages['access_token'];
if($name == 'Testing')
  {
      try {
        $response1 = $fb->get('/eventid', $cc);
        $page1 = $response1->getGraphNode()->asArray();
      } catch(Facebook\Exceptions\FacebookResponseException $e) {
        // When Graph returns an error
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
      } catch(Facebook\Exceptions\FacebookSDKException $e) {
        // When validation fails or other local issues
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
      }
    $page1 ['id'];

  }
  else

  {

  }
  }
  } 
drpzz
  • 55
  • 8
  • You need to specify the fields you want, see http://stackoverflow.com/a/32585470/1427878 – CBroe Feb 27 '17 at 08:42
  • Okay, i see. But how i'm suppose to get only attending list/count. Like if i want to compare the list with another list, how it's done? At the moment, fields?=attending gives me name, id, rsvp_status etc. How i'm suppose to get only the name from that array? – drpzz Feb 27 '17 at 12:38
  • By accessing the relevant element via its key …? That sounds less like a Facebook-specific question, and more like you might need to go read up on how to generally work with the PHP data types to be honest. – CBroe Feb 27 '17 at 12:42
  • I'm a beginner, but i'll google it. Thanks! – drpzz Feb 27 '17 at 15:39

0 Answers0