Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook graph API always returns small pictures

I'm using facebook graph api, and I issue this command

/V2.0/me/home

it returns something like :

  "id": "xxxxxxxxxxxxxxxxxxxxxx", 
  "from": {
    "id": "xxxxxxxxxxxxxxxxx", 
    "name": "Roger"
  }, 
  "story": "Roger shared a link.", 
  "picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQB2VeutsxS6ht3i&w=154&h=154&url=https%3A%2F%2Fwww.facebook.com%2Fads%2Fimage%2F%3Fd%3DAQIuWnred6mG7Ti280buWL8uhE00-W2H0Eom1PzNa3Av0x3y7JieMPqLmxAFYsCRKh0Zr8u_PyWO1lFbTknlj_DaksBoFiaD8d2yIWLOGNYKie1w9Kff6vyyElxnfrlHH7uSRhwycKNakg7szgWtBBwC", 
  "link": "http://xxxxxx.com", 

the issue is with the "picture" tag above, where the url to the picture is given after.

If you paste that url into your browser you get a small thumbnail size image, but on the real facebook page, its shows a much larger high resolution version of the same image.

This is the same for all the picture urls it sends back. Some url ends with _s.jpg, and I can change that to _n.jpg to make it a larger image, but that doesnt work for urls that doesnt have _s.jpg at the end, like the url above.

Anybody knows the facebook-graph-api command to use, so that facebook will send the url that points to the larger high resolution image instead of sending back urls that point to all thumbnails? Or how to change the url so that it points to the large high res image?

Thanks

like image 696
N S Avatar asked Jun 12 '14 04:06

N S


4 Answers

Using the user's id in place of <id>, you can get a larger resolution image at:

http://graph.facebook.com/<id>/picture?type=large

like image 162
NodeDad Avatar answered Oct 08 '22 04:10

NodeDad


After you get the "id" of a post in your news feed use (in JavaScript)

pic_url = 'http://graph.facebook.com/'+ post_id +'?fields=full_picture&access_token="+ response.authResponse.accessToken;

in your request.

Example response:

{
   "full_picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQBbJqpkt2Jhf0VF&url=http\u00253A\u00252F\u00252Fwww.mixofpix.eu\u00252Fwp-content\u00252Fuploads\u00252F2014\u00252F08\u00252Flampa-oblak.jpg",
   "id": "1407721719477425_1467737580142505",
   "created_time": "2014-08-07T20:00:51+0000"
}
like image 40
Martin Danis Avatar answered Oct 08 '22 02:10

Martin Danis


Get the ObjectId from field "object_id" for a specific post from your news feed

Use this object_id value to make a separate Graph API call as follows -

https://graph.facebook.com/10152199489086727?fields=images&access_token=

This will return the list of images of varying sizes for this post.

Example output:

{
    "images": [
    {
        "height": 462, 
        "source": "https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpf1/t1.0-9/10302057_10152199489086727_707407897349696496_n.jpg", 
        "width": 616
    }, 
    {
        "height": 320, 
        "source": "https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpf1/t1.0-9/p320x320/10302057_10152199489086727_707407897349696496_n.jpg", 
        "width": 426
    },.... ..
    ], 
    "created_time": "2014-07-23T18:15:16+0000", 
    "id": "10152199489086727"
}
like image 3
Satyajit Paul Avatar answered Oct 08 '22 02:10

Satyajit Paul


Try specifying the attachments field in your request.

/v2.0/me/home?fields=attachments

This will give you an 'attachments' field, with some media inside. You'll find there high res images.

like image 2
ecdeveloper Avatar answered Oct 08 '22 04:10

ecdeveloper