2014-10-10 65 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 */ 
        }]; 

結果是一種字典。您還可以在「封面」標籤下看到用戶封面照片的鏈接,以及其「源」標籤。