Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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": {
            "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"
         },
like image 898
hsz Avatar asked Jun 27 '11 08:06

hsz


1 Answers

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".

like image 74
Niklas Avatar answered Oct 01 '22 18:10

Niklas