facebook - Graph API: Retrieving picture dimensions in page feed -
i'm using graph api wall post of fan page.
i noticed facebook ios app able determine exact ratio placeholder.
http://developers.facebook.com/tools/explorer?method=get&path=facebook%2ffeed%3ffields%3dpicture
{ "data": [ { "picture": "http://photos-b.ak.fbcdn.net/hphotos-ak-frc1/247019_457846347622804_946521095_s.jpg", "id": "20531316728_10151883063741729", "created_time": "2013-05-02t16:57:25+0000" }, : : : { "picture": "http://photos-e.ak.fbcdn.net/hphotos-ak-ash4/223257_10151498310776729_930531604_s.jpg", "id": "20531316728_10151498193061729", "created_time": "2012-10-05t18:42:38+0000" } ], "paging": { "previous": "https://graph.facebook.com/20531316728/feed?fields=picture&limit=25&since=1367513845", "next": "https://graph.facebook.com/20531316728/feed?fields=picture&limit=25&until=1349462557" } }
there contains no information of pictures' dimension in api response, i'd have correct placeholder size custom client facebook ios app.
i tried adding /facebook/feed?fields=picture,width,height no luck in retrieving corresponding information.
is there possible way retrieve pictures's height , width param api itself?
no, api doesn't return all picture's dimensions based on post feed /page_id/feed or stream table.
i mentioned because, can is:
select post_id, created_time, actor_id, attachment, message stream source_id=page_id , created_time<now() limit 50
if post type photo:
if post type video:
if post type link start fbexternal (extract parameter w , h):
if post type link without fbexternal (facebook photo), stuck here!:
code prototype:
if attachment: image_url = attachment.media[0].src if image_url: m = image_url.photo.images if m: if m.src == image_url: image_width = m.width image_height = m.height else: #no dimensions info if host fbexternal: #extract parameter w , h https://fbexternal-a.akamaihd.net/safe_image.php?d=aqbhfbzbnudc_se8&w=130&h=130&url=http%3a%2f%2f image_width = 130 image_height = 130 else: stuck here, hard extract photo id based on url, lot of work!
in conclusion, highly recommend image width , height after download photo. example, php have getimagesize function , python have python imaging library (pil).
Comments
Post a Comment