简体   繁体   中英

Facebook graph API iOS : How to get width and height of a feed picture?

[facebook requestWithGraphPath:@"me/home" andParams:params andDelegate:self];

and I got result like these:

"===========================================

"id": "619421723284_367295343463689",

"from": {

"name": "ChED Ying",

"id": "619421784" },

"story": "Chanered McDonald's Singapore's photo.",

"picture": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash3/542908_38595311133451268_195dfdd7739613_s.jpg",

"link": "https://www.facebook.com/photo.php?fbid=385953111451268&set=a.161567683889813.28585.157162220997026&type=1",

"name": "Wall Photos",

"=========================================

I know how to get large version of a feed picture element by replacing _s.jpg to _n.jpg but picture's size no idea

.

Can anybody help me?

Thanks.

You can get the width and height of the image like this:

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString: @"https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash3/542908_38595311133451268_195dfdd7739613_s.jpg"]];
UIImage *image = [UIImage imageWithData:data];
NSLog(@"%f, %f", image.width, image.height);

Not possible with this API, I tried all possible fields ;-(

  1. From Php you can load some bytes of the image (HTTP Range header) and read the JPG header
  2. You can re-query Facebook, to get the photo object itself from this ID (I am using FQL API, with attachement field)

It's very annoying ;-(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM