【发布时间】:2016-09-17 17:49:29
【问题描述】:
我正在尝试保存一些从 Facebook 提取的当前用户信息并将其保存到我的解析数据库中。我已成功保存名称,但保存照片时遇到很多问题。这是我的代码:
FBSDKGraphRequest(graphPath: "me",
parameters: ["fields": "id, name,friends, first_name, last_name, picture.type(large), email, gender,taggable_friends"])
.startWithCompletionHandler({ (connection, result, error) -> Void in
print(String(result["picture"]))
PFUser.currentUser()!["name"] = String(result["name"])
let imageData = UIImagePNGRepresentation(result["picture"])
let imageFile = PFFile(name:"image.png", data:imageData)
PFUser.currentUser()?["imageFile"] = imageFile
PFUser.currentUser()?.saveInBackground()
})
任何帮助将不胜感激。
【问题讨论】:
-
如果您只想保存一次图像(用户在 Facebook 中更改图像时不刷新),请按照 JVS 回答。如果您希望每次用户在 Facebook 上更改图像时都会更改图像,您可以将用户 Facebook ID 保存在特定列中,然后在客户端构造获取图像的 URL。
标签: ios swift xcode facebook parse-platform