1

I'm using the PHP Facebook API (together with laravel)

I can manage to get the feed from a page, with all it's post using

    $request = Facebook::get('/COMPANYPAGE?fields=feed.limit(25)');
    $response = $request->getGraphPage()->getField('feed');

This returns the following objects

enter image description here

But I can't seem to get the specific information for that post! Like the images included.. Is there another call I need to perform?

I tried the following but it's giving me back the same results

    $request = Facebook::get('/elbeko?fields=feed.limit(25)');
    $response = $request->getGraphPage()->getField('feed');

    foreach($response as $item) {
        $post = Facebook::get($item['id'])->getGraphObject();
    }
Miguel Stevens
  • 8,631
  • 18
  • 66
  • 125
  • @CBroe I dont think that this is a duplicate of the post mentioned above. this one belongs to page-posts while the other one asks for user-posts – Felix Geenen Jul 13 '17 at 18:14
  • @FelixGeenen the underlying change is the same for all API endpoints - you need to ask for the fields you want. One answer there links to the changelog, and that explains the issue without even specifically mentioning pages or user profiles. And why should it, since it is the same for all. – CBroe Jul 13 '17 at 18:27

1 Answers1

14

From v2.4 on, you have to specify each field you want to have returned from the Grpah API. You should be able to use

/elbeko/feed?fields=id,message,link,attachments{media}&limit=25

which returns something like

{
  "data": [
   {
      "id": "1472127519670095_1645415342341311",
      "message": "Benieuwd naar ons nieuw project in de regio Gent? Binnenkort meer info via www.elbeko.be!",
      "link": "https://www.facebook.com/elbeko/photos/a.1589552831260896.1073741835.1472127519670095/1645415342341311/?type=3",
      "attachments": {
        "data": [
          {
            "media": {
              "image": {
                "height": 405,
                "src": "https://scontent.xx.fbcdn.net/hphotos-xpl1/v/t1.0-9/s720x720/11954813_1645415342341311_5204470874884096944_n.jpg?oh=0a7e10b12d3feb90b2de79fa60a7f8f8&oe=56C30337",
                "width": 720
              }
            }
          }
        ]
      }
    }
  ],
  "paging": {
    "previous": "https://graph.facebook.com/v2.5/1472127519670095/feed?fields=id,message,link,attachments%7Bmedia%7D&limit=2&format=json&since=1441790055&access_token=&__paging_token=&__previous=1",
    "next": "https://graph.facebook.com/v2.5/1472127519670095/feed?fields=id,message,link,attachments%7Bmedia%7D&limit=2&format=json&access_token=&until=1441124382&__paging_token="
  },
}

See

In the past, responses from Graph API calls returned a set of default fields. In order to reduce payload size and improve latency on mobile networks we have reduced the number of default fields returned for most Graph API calls. In v2.4 you will need to declaratively list the response fields for your calls.

Tobi
  • 31,405
  • 8
  • 58
  • 90