我如何从Facebook公共资料Facebook IOS Swift SDK获取性别 [英] how do i get gender from facebook public profile Facebook IOS Swift SDK

查看:156
本文介绍了我如何从Facebook公共资料Facebook IOS Swift SDK获取性别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要了解Facebook用户的性别的原因是因为我的应用仅适合女性,并且通过获取用户的性别可以解决很多应用问题.

The reason why I need to get the gender of the Facebook user is because my app is only cater for women and by getting the gender of the user could solve a lot of the app problem.

代码

loginManager.logIn(readPermissions: [ .publicProfile, .email ], viewController: self) { loginResult in
            switch loginResult {
            case .failed(let error):
                print(error)
            case .cancelled:
                print("User cancelled login.")
            case .success(_, _, let accessToken):

                if let userId = accessToken.userId {

                }


            }
        }

我从facebook服务器获得的结果

The result that I get from the facebook server

["picture": {
    data =     {
        height = 200;
        "is_silhouette" = 1;
        url = "https://www.picture.com";
        width = 200;
    };
}, "last_name": Test, "email": test123@gmail.com, "id": 1234556, "first_name": Airsoft]

我没有得到用户的性别.如何获得用户的性别?

I didn't get the gender of the user. How do I get the gender of the user?

致谢

推荐答案

您可以使用Graph api获取这些详细信息.检查此链接 https://developers.facebook.com/docs/graph-api /reference/user

You can get these details using Graph api. Check this link https://developers.facebook.com/docs/graph-api/reference/user

      let request = FBSDKGraphRequest(graphPath: "\(user-id)", parameters: ["fields" : "id,name,email,birthday,gender,hometown" ], httpMethod: "GET")
      request?.start(completionHandler: { (connection, result, error) in
        // Handle the result
      })

这篇关于我如何从Facebook公共资料Facebook IOS Swift SDK获取性别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆