开发者

Facebook API - get profile feed with authors' avatars

I am trying to fetch data from user's wall and it goes well - just simple request to Facebook Graph API:

https://graph.facebook.com/me/feed?access_token=...

However it returns:

"data": [
      {
         "id": "1337_123",
         "from": {
            开发者_Go百科"name": "Johny Rambo",
            "id": "1337"
         },
         "message": "hello world",
         ...
       },
       ...
]

What I also need is author's avatar (picture) - in that case Johny Rambo.

I can ask Facebook API for it with other request like:

https://graph.facebook.com/1337?access_token=...&format=json&fields=name,picture

But it makes a n+1 requests to the API (n - number of wall posts if authors are unique).

Is it possible to modify main request for wall posts to fetch from section with users' pictures like below ?

         "from": {
            "name": "Johny Rambo",
            "id": "1337",
            "picture": "http://profile.ak.fbcdn.net/......jpg"
         },


You can simply use the ID as the image with /picture:

<img src="https://graph.facebook.com/1337/picture"/>

You can render the current profile photo for any object by adding the suffix /picture to the object URL.

For more information, have a look at the documentation here under "pictures".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜