Pregunta

I am using restfb to get the number of likes in an specific post, and it was working well. Somehow, this morning it stopped working, and I didn't change anything in the code. The problem is on the following line:

posts.get(i).getJsonObject("likes").getString("count"))

After retrieving the posts from a page, when trying to get the number of likes that this post has, I get this:

com.restfb.json.JsonException: JsonObject["count"] not found.

I used Graph API Explorer to see if my search was working and to check if "count" appeared on the results, and it does:

  "likes": {
    "data": [
      {
        "name": "Kobi Parfait", 
        "id": "100000605529126"
      }, 
      {
        "name": "John Foley", 
        "id": "100002480987029"
      }, 
      {
        "name": "Camilla Slima", 
        "id": "1267755442"
      }, 
      {
        "name": "Augustine Paz", 
        "id": "677044677"
      }
    ], 
    "count": 198648
  },

I don't understand what is going on, can someone help?

Thanks in advance!

¿Fue útil?

Solución

on your application account you should have received an alert telling you that the functionality of the API is going to change and you need to make the appropriate changes to your code.

this is the blog post

The 'count' field was removed from the object. According to the documentation it was moved to the 'summary' section but it looks like they forgot to do so.

the only way i know to get the number of likes now is to go through all the like objects they give you (only 25 at a time) until you get to the end and count them youself.

edit

have a look at this post, aparently the 'summary' is within the 'likes' connection for the post object (i havent tried it)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top