【问题标题】:Get facebook user's uploaded photos in swift/xcode 6在 swift/xcode 6 中获取 facebook 用户上传的照片
【发布时间】:2014-12-13 22:44:57
【问题描述】:

我已经能够在 Xcode 6.1.1 中使用 swift 登录并获取名字、姓氏、电子邮件和个人资料图片 url。即使我拥有 user_photos 权限,我也无法弄清楚如何获取 URL 或从用户那里提取图像。任何帮助将不胜感激。

【问题讨论】:

    标签: facebook-graph-api swift xcode6


    【解决方案1】:

    您需要向图形 API 发出请求,该 API 将返回 JSON 以响应您的请求。例如,如果您想获取姓名、个人资料图片(它会为您提供个人资料图片的 url)和 id,您可以在 viewDidLoad() 中提出请求,如下所示

    FBRequestConnection.startWithGraphPath("me?fields=id,name,picture", completionHandler: {(connection: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void in
            if (result? != nil) {
                NSLog("error = \(error)")
    
                println(result)
            }
            } as FBRequestHandler)
    

    将标签文本设置为您可以使用的 facebook 名称

     var resultdict = result as? NSDictionary
                if let name = resultdict?["name"] as? String {
    
                    self.YOUR_LABEL.text = name //name is response object in "result" dictionary
    
                }
    

    干杯!!!

    【讨论】:

      猜你喜欢
      • 2014-12-23
      • 1970-01-01
      • 1970-01-01
      • 2015-10-18
      • 1970-01-01
      • 2019-03-22
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      相关资源
      最近更新 更多