简体   繁体   English

user_photos在Swift中列出访问权限

[英]user_photos List access in Swift

when I try retrieving Data from FacebookLogin with user_photos Permission, I get an error of access Token invalid 209. 当我尝试使用user_photos权限从FacebookLogin检索数据时,出现访问令牌无效209的错误。

I figured it is because i try to save the data in a non-typematching variable. 我想这是因为我试图将数据保存在非类型匹配变量中。

Could someone tell me how access the id of photos retrieved from Facebook? 有人可以告诉我如何访问从Facebook检索的照片ID吗?

        print(result["photos"])

Gives me: 给我:

     Optional({
         data =     (
            {
        "created_time" = "2015-07-26T20:57:23+0000";
        id = 920478361357710;
    },
            {
        "created_time" = "2015-02-14T20:24:23+0000";
        id = 961789147179683;
        name = "szlangini kickdown";
    },

} }

You can try this code: 您可以尝试以下代码:

let parmas = ["fields" : "id, name"]
    let request = FBSDKGraphRequest.init(graphPath: "me/photos", parameters: parmas
        , HTTPMethod: "GET")

    request.startWithCompletionHandler { (connection: FBSDKGraphRequestConnection!, result : AnyObject!, error: NSError!) -> Void in

        let listPhoto = result["data"]

        guard let unWrappedPhotos = listPhoto as? [AnyObject] else {
            return
        }

        for dict in unWrappedPhotos {
            guard let id = dict["id"] as? String  else {
                break
            }
            print(id)
        }

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM