简体   繁体   English

Facebook graph API iOS:如何获取提要图片的宽度和高度?

[英]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", “ id”:“ 619421723284_367295343463689”,

"from": { “来自”:{

"name": "ChED Ying", “名称”:“ ChED Ying”,

"id": "619421784" }, “ id”:“ 619421784”},

"story": "Chanered McDonald's Singapore's photo.", “ story”:“麦当劳(McDonald)新加坡的相片。”,

"picture": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash3/542908_38595311133451268_195dfdd7739613_s.jpg", “ 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", “ link”:“ https://www.facebook.com/photo.php?fbid=385953111451268&set=a.161567683889813.28585.157162220997026&type=1”,

"name": "Wall Photos", “ 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 我知道如何通过将_s.jpg替换为_n.jpg来获取提要图片元素的大版本,但是图片的大小不知道

.

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 ;-( 使用此API不可能,我尝试了所有可能的字段;-(

  1. From Php you can load some bytes of the image (HTTP Range header) and read the JPG header 从Php中,您可以加载图像的某些字节(HTTP Range标头)并读取JPG标头
  2. You can re-query Facebook, to get the photo object itself from this ID (I am using FQL API, with attachement field) 您可以重新查询Facebook,以从此ID获取照片对象本身(我正在使用带有附件字段的FQL API)

It's very annoying ;-( 这很烦人;-(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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