Reputation: 303
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
Upvotes: 10
Views: 7509
Reputation: 1537
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
Upvotes: 11
Reputation: 2875
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.
Upvotes: 2
Reputation: 370
You can get the original image URL by grabbing the value of the url
query string variable in the 'picture' property of the post and decode it:
var origImgSrc = decodeURIComponent(picture.match(/(url=)([^&]+)/)[2]);
The other (more thorough/heavier) alternative would be to send a batch request to the Facebook Graph API, with the first request getting the feed from me/home/ and then the second using ?ids= to look up any returned object_id properties (for photos/videos on Facebook).
You would do this by sending a POST request to https://graph.facebook.com
with the following in the request body:
access_token=VALID_ACCESS_TOKEN&batch=[{%20%22method%22:%22GET%22,%22name%22:%22me_home%22,%20%22relative_url%22:%22me/home?fields=object_id,full_picture%22,%20%22omit_response_on_success%22:false},%20{%20%22method%22:%22GET%22,%20%22depends_on%22:%22me_home%22,%20%22relative_url%22:%22?ids={result=me_home:$.posts.data.*.object_id}%22}]
Then you can do some fancy JS parsing to get either the full_picture property or one of the source properties from the images array for the object.
Upvotes: 0
Reputation: 49
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"
}
Upvotes: 4
Reputation: 345
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"
}
Upvotes: 3