Facebook devuelve un recuento incorrecto de comentarios de publicaciones

I encounter the following issue in my Java Android app:

When I create a comment for a post (send a request to FB) I get a successful response (I get the ID for a newly created comment for the post). Good so far.

But if then I immediately call for comments count:

"SELECT comments.count FROM stream WHERE post_id = '" + postId + "'"

then instead of getting expected 1 (assuming it was the first comment), I get 0 (FB tells there is no comments at all). My question is why this happens? The issue goes away if I wait for some time. E.g., if I wait for about a minute, then FB starts returning expected comments count.

It looks like (just my guess) that FB has no sufficient time to update its indexes (I really believe they use indexing). So I get an obsolete/cached resutls. I wonder is there any means to force getting the freshest data (bypassing any caches on FB side)?

Una clarificación: I know how to get a list of comments. And I could use it for getting count just by getting size from the returned collection. But that is not my goal. Because the posted above FQL request should be in times cheaper/faster.

preguntado el 31 de julio de 12 a las 11:07

1 Respuestas

Have you tried using FB API for this. Comments can be fetched as following.

FB.api("/" + PostId + "/comments", function(){//do your processing})

Espero que esto ayude.

Muchas Gracias


Respondido 31 Jul 12, 14:07

I am not asking about the way to get a list of comments - that is not a problem and works fine. What I'm asking is related to getting the count of comments for a post. There is API for that, but it returns a wrong count. Why? And how to force it returning correct (freshest) value? - Vit Khudenko

The FB API call that I mentioned will give JSON Array. Length of that array can be used as number of comments. - Purusottam Kaushik

thanks. Surely I understand that, but that is not what my question is about. - Vit Khudenko

@Arhimed i feel your pain. Clearly he has never worked with the FB API at scale--one cannot blindly fetch comments without knowing what they're getting themselves into (via the count). If there are > than 25 comments, you cannot use the length of the comments array in the JSON, as there may be thousands of comments lurking beyond page 1 ;-) - Stantonk

Try to filter your posts by their type (photo, status, video, link ...) and request the comment_info where you can find the comment_count of that specific post inside the returned object. SELECT comment_info FROM photo WHERE object_id = 123456789 - djokage

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.