【问题标题】:FBSDKLog: starting with Graph API v2.4, GET requests for /me/permissions should contain an explicit "fields" parameterFBSDKLog:从 Graph API v2.4 开始,对 /me/permissions 的 GET 请求应包含显式的“字段”参数
【发布时间】:2015-09-12 14:00:15
【问题描述】:

有人知道我为什么会收到这个错误吗?我有一个字段参数集。我是 swift 和编码的新手,任何帮助将不胜感激。

let graphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, gender"])

    // start the request:
    graphRequest.startWithCompletionHandler({

        // void in means that it will return nothing upon completion
        (connection, result, error) -> Void in

        // do an error check
        if error != nil {


            print(error)


        } else if let result = result {

            PFUser.currentUser()?["gender"] = result["gender"]
            PFUser.currentUser()?["name"] = result["name"]
            PFUser.currentUser()?.save()


            // use the user's FB id to get their public profile. First make their id a string:
            let userId = result["id"] as! String
            // next go to the internet and get their photo from FB:
            let facebookProfilePictureUrl = "https://graph.facebook.com/" + userId + "/picture?type=large"

【问题讨论】:

    标签: ios xcode facebook swift


    【解决方案1】:

    有一种方法可以让你得到对象“我”,然后你可以获取它的每一个值

    let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: nil)
        graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
            if (error) != nil   {
                NSLog("Error: \(error)")
                ActivityIndicatorWithLabel.shared.hideProgressView()
                view.makeToast(message: "We are unable to connect to Facebook. Please try after sometime")
            }else{
                self.facebookData(result)
            }
        })
    

    在这个结果中,我们得到了用户的所有详细信息 这是一种从中获取的方法

    func facebookData(result: AnyObject){
        NSLog("Sending Login from facebook call")
        var missingFields:[String] = []
        userSocialDetailsGlobal.loginType = "facebook"
        userSocialDetailsGlobal.socialId = result.valueForKey("id") as! String
        userSocialDetailsGlobal.firstName = result.valueForKey("first_name") as! String
        userSocialDetailsGlobal.lastName = result.valueForKey("last_name") as! String
    
        userSocialDetailsGlobal.socialToken = FBSDKAccessToken.currentAccessToken().tokenString
    }
    
    struct userSocialDetailsGlobal {
        static var socialId: String = String()
        static var firstName: String = String()
        static var lastName: String = String()
        static var loginType: String = String()
        static var socialToken: String = String()
    }
    

    【讨论】:

    • 请指定userSocialDetails全局变量
    猜你喜欢
    • 2015-11-08
    • 1970-01-01
    • 2020-08-19
    • 1970-01-01
    • 2016-08-22
    相关资源
    最近更新 更多