How to get all post from a page with count ALL lik

2019-08-28 16:36发布

attached got a question ... I try with all feeds Likes and Comments retrieve a page during a period. or .. actually I only need the total number of likes and comments overall.

So far ...

$user_pages = $facebook-> api ('/ me / accounts');

  ...

$page_feeds = $facebook-> api ("/". $ page_name ['id']. '/ feed', 'GET', array ('limit' => 10000, 'since' => mktime (0,0, 0, date ("m"), 1, date ("Y"))));

  ...

foreach ($page_feeds ['data'] as $ page) {

    $c = $facebook-> api ("/" $ page ['id'] "/ likes", "GET", array ('limit' => 10000)..);
    $temp ['likes'] = count ($ c ['data']);

    $c = $ facebook-> api ("/" $ page ['id'] "/ comments", "GET", array ('limit' => 10000)..);
    $temp ['comments'] = count ($ c ['data']);

}

  .....

So I get all the pages in which I am admin, then all feeds the Page since the first of the month. This has been going on forever until the answer is there. But the problem is I only get max 25 max 25 Likes and Comments. (the word "counts" as described in the API documentation but I missing here.

So now I have to call in the loop every feed all the likes and comments on it and then to get the number.

These queries take now to three minutes ... which is clearly too long ...

Is not it ne nice way? I have been able to find anything. I was hoping I this query

$page_feeds = $ facebook-> api ("/". $ page_name ['id']. '/ feed', 'GET', array ('limit' => 10000, 'since' => mktime (0,0, 0, date ("m"), 1, date ("Y"))));

can adjust, and then ALL likes and comments (or at least the numbers) to get

150769909716/feed?fields=likes.limit(10000).fields(id),comments.limit(10000).fields(id)&limit=10000&since=1372608000

unfortunately gives me back a maximum of only 25 likes and comments.

Timo

#

Edit:

https://graph.facebook.com/[pageid]/feed?fields=likes.limit%2810000%29.fields%28id%29,comments.limit%2810000%29.fields%28id%29&locale=de_DE&since=1372608000&limit=10000&access_token=yyyy

give me:

{
   "data": [
      {
         "id": "xxx_xxx",
         "created_time": "2013-07-23T07:08:25+0000",
         "likes": {
            "data": [
               {
                  "id": "xxxx"
               },
            ],
            "paging": {
               "cursors": {
                  "after": "xxx",
                  "before": "xxxx"
               },
               "next": "xxxx"
            }
         },



https://graph.facebook.com/[pageid]/feed?since=1372608000&limit=10000&access_token=yyyy

giv me: (yes, my Count is there...but only browsercall)

"likes": {
            "data": [
               {
                  "name": "xxx",
                  "id": "xxx"
               },
                ],
            **"count": 53**
         },

the same call per call give me the result without Count data....

1条回答
戒情不戒烟
2楼-- · 2019-08-28 17:14

Unfortunately Facebook has removed as you have seen the total count of likes and comments when you look at posts. Instead you need to make another call for each post to retrieve the total likes or comments. Also they have renamed it from count to total_count

Example:

For likes

https://graph.facebook.com/POST_ID/likes/?summary=true

it will return something like this

{
  "data": [
    {
      "id": "xxxx",
      "name": "xxxxx"
    },
    {
      "id": "xxxx",
      "name": "xxxxx"
    },
    {
      "id": "xxxx",
      "name": "xxxxx"
    },
    {
      "id": "xxxx",
      "name": "xxxxx"
    }
  ],
  "paging": {
    "cursors": {
      "after": "NTU2MTU3NjU0",
      "before": "MTA4OTM4NzgwMA=="
    }
  },
  "summary": {
    "total_count": 4
  }
}

For comments:

https://graph.facebook.com/POST_ID/comments/?summary=true

{
  "data": [
    {
      "id": "xxxxx",
      "from": {
        "category": "Media/news/publishing",
        "category_list": [
          {
            "id": "xxxxxx",
            "name": "xxxx"
          },
          {
            "id": "xxxxxx",
            "name": "xxxx"
          }
        ],
        "name": "xxxxx",
        "id": "xxxxx"
      },
      "message": "xxxxxxx",
      "can_remove": false,
      "created_time": "2013-07-03T20:36:54+0000",
      "like_count": 0,
      "user_likes": false
    }
  ],
  "paging": {
    "cursors": {
      "after": "Mg==",
      "before": "Mg=="
    }
  },
  "summary": {
    "order": "ranked",
    "total_count": 2
  }
}
查看更多
登录 后发表回答