How to get picture of user who has commented on my

2019-09-10 07:08发布

问题:

I have post_id of the status which user share by iOS app, Now with graph api, I'm getting comment info and like info:

POST_ID?fields=likes.fields(pic_square,name),comments

With above, I'm able to fetch most of the details, but not profile pic of user who commented on post. check details which I'm getting:-

{
  "id": "POST_ID", 
  "updated_time": "2014-03-25T07:07:14+0000", 
  "likes": {
    "data": [
      {
        "pic_square": "https://fbcdn-profile-a.akamaihd.net/static- ak/rsrc.php/v2/yo/r/UlIqmHJn-SK.gif", 
        "name": "User name", 
        "id": "100007640XXXXX"
      }
    ], 
    "paging": {
      "cursors": {
        "after": "MTAwMDA3NjQwMzcxMzQxxx", 
        "before": "MTAwMDA3NjQwMzcxMzQxxx"
      }
    }
  }, 
  "comments": {
    "data": [
      {
        "id": "2069772628xxxxxx", 
        "from": {
                 "name": "user name", 
                 "id": "100007640xxxxxx"
                }, 
        "message": "great reader..", 
        "can_remove": true, 
        "created_time": "2014-03-26T06:19:36+0000", 
        "like_count": 0, 
        "user_likes": false
      }
    ], 
    "paging": {
          "cursors": {
          "after": "MQ==", 
         "before": "MQ=="
      }
    }
  }
}

Now I need picture of a user who commented on post, I'm getting picture of user who likes, but not who commented. I tried to get it with FQL but not succeed.

回答1:

Here in response you are getting user id who had liked your post so use that as follows

https://graph.facebook.com/10000445993xxxxx/picture?type=large



回答2:

Use this API:

https://graph.facebook.com/100007640xxxxxx/picture

100007640xxxxxx: is userid.

Edit:

if you want to load user picture in particular size then you can use following:

https://graph.facebook.com/100007640xxxxxx/picture?width=150&height=150