Facebook Graph API - Get like count on page/group photos

前端 未结 4 1097
感情败类
感情败类 2020-12-08 03:12

I\'ve been testing graph API and ran into a problem. How can I get like count from photos of a page/group?

I\'m administrator/creator of a group. When entering in ht

4条回答
  •  甜味超标
    2020-12-08 03:51

    You can get the comments/likes count without having to paginate through all likes by using the fields parameter in combination with likes.limit(1).summary(true). For example, a search api query for pizza below will give you all public posts and their likes count summarized:

    https://graph.facebook.com/search?q=pizza&type=post&fields=id,name,likes.limit(1).summary(true)
    

    results (truncated):

    {
      "data": [
        {
          "id": "47883936273_659693910762305", 
          "name": "Instagram", 
          "created_time": "2014-02-16T01:15:29+0000", 
          "likes": {
            "data": [
              {
                "id": "100002243084532", 
                "name": "Yvette Martin"
              }
            ], 
            "paging": {
              "cursors": {
                "after": "MTAwMDAyMjQzMDg0NTMy", 
                "before": "MTAwMDAyMjQzMDg0NTMy"
              }, 
              "next": "https://graph.facebook.com/47883936273_659693910762305/likes?limit=1&summary=1&after=MTAwMDAyMjQzMDg0NTMy"
            }, 
            "summary": {
              "total_count": 13682
            }
          }
        }, 
        {
          "id": "136336876521150_314001148754721", 
          "name": "Pizza Box Turns into Plates & Storage Unit!", 
          "created_time": "2014-02-15T21:20:00+0000", 
          "likes": {
            "data": [
              {
                "id": "100005373008864", 
                "name": "Liliana Campoli"
              }
            ], 
            "paging": {
              "cursors": {
                "after": "MTAwMDA1MzczMDA4ODY0", 
                "before": "MTAwMDA1MzczMDA4ODY0"
              }, 
              "next": "https://graph.facebook.com/136336876521150_314001148754721/likes?limit=1&summary=1&after=MTAwMDA1MzczMDA4ODY0"
            }, 
            "summary": {
              "total_count": 2792
            }
          }
        }
    

提交回复
热议问题