The following on the attachment below are the page feeds with its comments returned by facebook PHP sdk and Graph API.
What I want here is to get number of comments per user on each feed.
Here are the codes
$helper=new FacebookRedirectLoginHelper($url);
try{
$session=$helper->getSessionFromRedirect();
if(isset($session))
{
$request=(new FacebookRequest($session,"GET","/357971644373038/feed"))->execute()->getGraphObject()->asArray();
$comment=$request["data"];
$counter=count($comment,1);
for($index=0; $index<$counter; $index++)
{
echo $request["data"][$index]->id."<br>";
echo $request["data"][$index]->message."<br><br>";
echo $this->get_stream(array("session"=>$session,"idfeed"=>($request["data"][$index]->id)))."<br><br>";
}
// print_r($request);
}
else{
$permision=array("scope"=>"email,publish_actions");
echo "<a title=".$helper->getLoginUrl($permision)." href='".$helper->getLoginUrl($permision)."'>Login here</a>";
}
}
catch(Exception $ex)
{
}
}
private function get_stream($data)
{
$request=(new FacebookRequest($data["session"],"GET","/".$data["idfeed"]."/comments"))->execute()->getGraphObject()->asArray();
if(isset($request["data"]))
{
//$count=0;
foreach($request["data"] as $result)
{
return json_encode($request["data"]);
}
// return json_encode($request["data"]);
}
}
Please I need your help guys....