简体   繁体   中英

How to get all post from a page with count ALL likes and comments?

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:

{
   "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

give me:

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

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....

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
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM