When I get the comments of a post
I get the comment, the person's name (and id), but not their profile picture.
To recover his profile picture, I must repeat each time a GET query
So if there are 150 comments, I make 150 GET queries just to retrieve the URL of the profile photo...
Page loading time sometimes takes up to 30 seconds...
Is it possible to recover url fields of the profile photo directly in the JSON with all comments?
Why would you need to retrieve the profile picture URLs in the first place? You have the user ids already, so you can simply use https://graph.facebook.com/v2.4/{user_id}/picture
as the src
attribute value of an img
element directly – it will redirect to the correct location of the actual image on Facebook’s CDN.
Or do you need the actual image URLs for another purpose, outside of the realm of a web page …?
In that case, you can use the Field Expansion feature of the API (so you don’t need a batch request):
/post_id/comments?fields=message,from{name,picture}
That will get you the content of the comment, plus the name and profile picture URL of the user that made the comment. (If you need any more fields, you have to add them to the list.)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments