2017-01-10 47 views
0

我已經完成了從Swift 3中的應用程序的FB登錄。現在,我需要從Facebook獲取個人資料圖片。 Plzz誰能給我Swift 3中的解決方案?從swift中獲取FB中的用戶信息

+0

參見:http://stackoverflow.com/questions/28333951/getting-profile-picture-with-swift-through-facebook-graph-api-return-unsupporte –

+0

你有任何錯誤,同時獲取圖片? – Birendra

+0

不,任何錯誤!它顯示除了顯示圖片爲空之外的所有內容... @ Birendra –

回答

0

請試試這個。

let login = FBSDKLoginManager() 

     login.logIn(withReadPermissions: ["email"], from: self) { (result, error) -> Void in 

      if (error != nil) { 

       self.view.makeToast("Error") 
      } 
      else if (result?.isCancelled)! { 

       self.view.makeToast("Cancel") 
      } 
      else { 

       if (FBSDKAccessToken.current() != nil) { 

        FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"id,interested_in,gender,birthday,email,age_range,name,picture.width(480).height(480)"]).start(completionHandler: { (connection, result, error) -> Void in 

         print(result) 
}) 
       } 
      } 
     } 
+0

你能解決我在那裏完成的方式嗎?我已經提取了所有其他數據,只有現在我需要獲取圖片。提前謝謝@ Keyur Hirani –

+0

可能會聽到許可問題。將picture.type(大)替換爲picture.width(480).height(480) –

+0

我做到了...仍顯示爲空。 @ Keyur Hirani –