Facebook how to get actual photo URL using Graph API

facebookfacebook-graph-api

It is possible to get the actual image url of a Facebook image using the Graph api??

For instance, for the below photo
http://www.facebook.com/photo.php?fbid=357755307655174

the actual URL is
https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-ash4/252428_530045532341_5136_n.jpg

Is there some graph api way to achieving this?

Best Answer

By default, not all fields in a node or edge are returned when you make a query. You can choose the fields or edges that you want returned with the fields query parameter.

That's why when you retrieve a photo, you may only get created_time, name and id.

source field is deprecated in latest API (v2.8). Use images instead.

So your query may look like this:

GET graph.facebook.com/{photo-id}?fields=images

Response should be like this:

{

"images":[
    {
        "height":358,
        "source":"https://scontent.xx.fbcdn.net/v/t1.0-9/15327427_585435148333529_xxxxxxxxxxxx_n.jpg?oh=xxxxxxxx&oe=xxxxxxxxx",
        "width":518
    },
    {
        "height":320,
        "source":"https://fb-s-c-a.akamaihd.net/h-ak-xtl1/v/t1.0-0/p320x320/15327427_xxxxxxxxxxxxxx_n.jpg?oh=xxxxxxxxxx&oe=xxxx&__gda__=xxxxxxxxxxxx",
        "width":463
    },
    {
        "height":130,
        "source":"https://fb-s-c-a.akamaihd.net/h-ak-xtl1/v/t1.0-0/p130x130/15327427_xxxxxxxxxxxxxx_n.jpg?oh=xxxxxxxxxxx&oe=xxx&__gda__=xxxxxxxxxxxxxxxxxx",
        "width":188
    },
    {
        "height":225,
        "source":"https://fb-s-c-a.akamaihd.net/h-ak-xtl1/v/t1.0-0/p75x225/15327427_xxxxxxxxxxxxxxx_n.jpg?oh=xxxxxxxxxxxxxxxxx&oe=xxxxxxxxxxxxxxxxxx&__gda__=xxxxxxxxxxxxxxxxxx",
        "width":325
    }
],
"id":"585435148333529"

}
Related Topic