-1

I am getting the posts of the group that I am an admin of through facebook graph api, now I also need to get the name/id of the person who has posted on the group. currently i am only getting the story, message, updated time, date and id of post.

Here is my try what I've done so far.

<?php
$fb = new Facebook\Facebook([
  'app_id' => '9298xxxx471393',
  'app_secret' => '18afexxxxxxxxxxxxxxd1656046',
  'default_graph_version' => 'v2.4',
  'default_access_token' => isset($_SESSION['fb_token']) ? $_SESSION['fb_token'] : '92980xxxxx1393|18afe9exxxxxxx73ed2cxxx56046'
]);  

getGroupFeed($fb);
function getGroupFeed($fb){

    $request = $fb->request('GET', '/17168xxxxxx762/feed');
    $response = $fb->getClient()->sendRequest($request);
    $feed = $response->getGraphEdge();

    $arraY = json_decode($feed, true);
    foreach ($arraY as $post) {
        print_r($post);
        echo "</br>--------------------</br>";
    }
}
 ?>

This is The Result I am getting from above code

Array ( [message] => This is a test message [updated_time] => Array ( [date] => 2016-04-12 10:51:55.000000 [timezone_type] => 1 [timezone] => +00:00 ) [id] => 1716867908529762_1716889168527636 )

Please Tell Is it possible to get name/id of person who post it, if yes then please guide any help will be appreciated.

Asad Mehmood
  • 315
  • 1
  • 3
  • 20

1 Answers1

1

You can get this done by adding fields parameter (from)

1716XXXXX08529762/feed?fields=from

it will give you

{
  "from": {
    "name": "Noman Ali",
    "id": "13XXXX4035XX7"
  },
  "id": "171XXXXXX9762_17169XXXXX22558"
},
Noman Ali
  • 3,160
  • 10
  • 43
  • 77