2014-10-10 33 views
0

如何获得的Facebook页面封面照片使用的是iOS SDK, 从解析的JSON结果我得到,下面的结果,但是,不能从那里封面照片,让Facebook页面的封面照片。如何使用的是iOS SDK

{ 
    actions =  (
       { 
      link = "https://www.facebook.com/100007281559316/posts/1487360021516702"; 
      name = Comment; 
     }, 
       { 
      link = "https://www.facebook.com/100007281559316/posts/1487360021516702"; 
      name = Like; 
     } 
    ); 
    "created_time" = "2014-10-10T04:09:22+0000"; 
    description = "Loneliness is a good feeling when it is created by Ourself. But . .it is the worst feeling when it is Gifted by others.\nExpecting your Opinion [email protected]"; 
    from =  { 
     id = 100007281543425252416; 
     name = "Hari Krishna"; 
    }; 
    icon = "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif"; 
    id = "100007281559316_1487360021516702"; 
    link = "https://www.facebook.com/Ekantatha"; 
    message = "https://www.facebook.com/Ekantatha"; 
    name = "\U0d0f\U0d15\U0d3e\U0d28\U0d4d\U0d24\U0d24"; 
    picture = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/c6.0.200.200/p200x200/1779801_631456453593885_482158404_n.jpg?oh=8f766377fc71b8e3703e330067a70ebc&oe=54C1FF93&__gda__=1421213700_5f4ec6aea535e630c1a5a1eace45f34b"; 
    privacy =  { 
     allow = ""; 
     deny = ""; 
     description = "Only Me"; 
     friends = ""; 
     networks = ""; 
     value = SELF; 
    }; 
    properties =  (
       { 
      name = Community; 
      text = "1,102 like this"; 
     } 
    ); 
    "status_type" = "shared_story"; 
    type = link; 
    "updated_time" = "2014-10-10T04:09:22+0000"; 
} 

编辑:

我要显示这样我的手机,所以我需要的封面照片这一点。从json结果我没有得到页面Id。如何使用iOS SDK获取页面的封面照片?

enter image description here

回答

0

这是一个后JSON你在这里展示,其中有无关请求页面的封面。

后者可以通过呼叫

GET /{Page_ID/?fields=id,name,cover 

其中{Page_ID/是ID或所讨论的页的名称来进行。对于可口可乐,结果看起来像

{ 
    "id": "40796308305", 
    "name": "Coca-Cola", 
    "cover": { 
    "cover_id": "10152297032458306", 
    "offset_x": 0, 
    "offset_y": 0, 
    "source": "https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-prn2/v/t1.0-9/s720x720/625442_10152297032458306_574021701_n.jpg?oh=54a129979e8786632b41e445db571749&oe=54B094E9&__gda__=1421627392_0061b39b7d81a3356a2b8a82a65b3839" 
    } 
} 
+0

from json result not get page Id。所以我该如何使用它? – 2014-10-10 06:42:53

+0

我不明白。您正在发布用户生成的帖子JSON,这是完全不同的!没有涉及的页面,所以这是行不通的! – Tobi 2014-10-10 06:44:50

+0

我从我/家里得到这个json结果。我怎样才能得到页面ID,获取封面照片。 – 2014-10-10 06:48:07

2

这是一个更新的解决方案。

var basicUserData = ["fields": "cover,picture,id,birthday,email"] 

FBRequestConnection.startWithGraphPath("/me", 
    parameters: basicUserData, 
    HTTPMethod: "GET") { 
     (connection:FBRequestConnection!, result, error) -> Void in 
      if error != nil { 
       print(error!) 
      } else { 
       print(result!) 
      } 
     } 

解析团队建议通过访问https://graph.facebook.com/(facebookId)/picture?type=large确保与用户的Facebook ID来代替让FB资料图片。 Here is the discussion

注:

+0

我需要获取Facebook页面的封面照片。不是用户封面照片。 – 2014-11-11 03:54:25

+0

只是为字段数组添加封面 – jpotts18 2014-11-11 23:42:20

1

对于IOS; 我已经使用https://graph.facebook.com/facebookuserid?fields=cover链接,但它没有工作。当我搜索Facebook SDK文档时,我看到了可行的答案。我希望这会对你有所帮助。

[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"/%@?fields=cover", [user objectForKey:@"id"]] 
        completionHandler:^(
             FBRequestConnection *connection, 
             id result, 
             NSError *error 
            ) { 
         NSLog(@"%@",[[result objectForKey:@"cover"]objectForKey:@"source"]); 
         /* handle the result */ 
        }]; 

结果是一种字典。您还可以在“封面”标签下看到用户封面照片的链接,以及其“源”标签。