PHP Facebook Graph API get posts comments WITH user photo field

Fabien

When I get the comments of a post

https://graph.facebook.com/v2.4/POST_ID/comments

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

https://graph.facebook.com/USER_ID/picture?redirect=false

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?

CBroe

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Facebook Graph API - page/posts - how to get photo url?

From Dev

Facebook Graph API - Get user feed posts with pictures

From Dev

Facebook Graph Api - Retrieve only Wall posts that contain a photo

From Dev

Get thumbnail of a photo with facebook graph api

From Dev

Facebook Graph API get tagged photo users

From Dev

Get facebook friends posts using graph API

From Dev

Facebook Graph API Get Comments outside of Wall

From Dev

get user info like name , photo and profile picture after using facebook login without graph API

From Dev

How to get user posts using Graph API?

From Dev

Get user wall feed posts with custom filter using Facebook Graph API

From Dev

Get Facebook User Email Using Graph API PHP SDK

From Dev

Facebook Graph API Fetching User's Profile Photo

From Dev

Facebook Graph API Fetching User's Profile Photo

From Dev

Facebook Graph API - Tag Photo

From Dev

Get Total Photo Count via Facebook Graph API

From Dev

Get Total Photo Count via Facebook Graph API

From Dev

How to count likes/comments of a photo/post using new Facebook Graph API 2.1?

From Dev

How to get the total number of posts in a Facebook page with Graph API?

From Dev

Facebook Graph API get all posts on group page

From Dev

Facebook Graph Api : Missing comments

From Dev

Facebook Graph Api : Missing comments

From Dev

Get tags on user photos facebook graph api

From Dev

Facebook Graph API (How to get user gender?)

From Dev

How to get Facebook posts of a page with its comments?

From Dev

how do i get facebook photo of public user in php

From Dev

Does Facebook Realtime API with webhook works with Page comments and User Posts as well?

From Dev

Facebook Graph API/SDK .NET - Get PageID of a Facebook user

From Dev

How to get the Facebook "HashTag" feeds/Posts etc using the Facebook Graph API ? I want to get all the posts of a particular #HashTag

From Dev

What's the proper way to update the "published" field on a Photo using the Facebook Graph API?

Related Related

  1. 1

    Facebook Graph API - page/posts - how to get photo url?

  2. 2

    Facebook Graph API - Get user feed posts with pictures

  3. 3

    Facebook Graph Api - Retrieve only Wall posts that contain a photo

  4. 4

    Get thumbnail of a photo with facebook graph api

  5. 5

    Facebook Graph API get tagged photo users

  6. 6

    Get facebook friends posts using graph API

  7. 7

    Facebook Graph API Get Comments outside of Wall

  8. 8

    get user info like name , photo and profile picture after using facebook login without graph API

  9. 9

    How to get user posts using Graph API?

  10. 10

    Get user wall feed posts with custom filter using Facebook Graph API

  11. 11

    Get Facebook User Email Using Graph API PHP SDK

  12. 12

    Facebook Graph API Fetching User's Profile Photo

  13. 13

    Facebook Graph API Fetching User's Profile Photo

  14. 14

    Facebook Graph API - Tag Photo

  15. 15

    Get Total Photo Count via Facebook Graph API

  16. 16

    Get Total Photo Count via Facebook Graph API

  17. 17

    How to count likes/comments of a photo/post using new Facebook Graph API 2.1?

  18. 18

    How to get the total number of posts in a Facebook page with Graph API?

  19. 19

    Facebook Graph API get all posts on group page

  20. 20

    Facebook Graph Api : Missing comments

  21. 21

    Facebook Graph Api : Missing comments

  22. 22

    Get tags on user photos facebook graph api

  23. 23

    Facebook Graph API (How to get user gender?)

  24. 24

    How to get Facebook posts of a page with its comments?

  25. 25

    how do i get facebook photo of public user in php

  26. 26

    Does Facebook Realtime API with webhook works with Page comments and User Posts as well?

  27. 27

    Facebook Graph API/SDK .NET - Get PageID of a Facebook user

  28. 28

    How to get the Facebook "HashTag" feeds/Posts etc using the Facebook Graph API ? I want to get all the posts of a particular #HashTag

  29. 29

    What's the proper way to update the "published" field on a Photo using the Facebook Graph API?

HotTag

Archive