如何从 google 获取用户生日并在 ios 中使用 oauth 2 api?

How to get user birthday from google plus using oauth 2 api in ios?

我已经在我的应用程序中实现了 Google 加号登录,现在我想通过 Google OAuth 获取用户生日 api.I 已经使用 google 开发人员获取用户生日playground.but 现在我想知道如何以编程方式在 iOS(swift) 中获取用户生日?

任何帮助将不胜感激。

您可以通过 Google 并使用 oauth api 以这种方式获取生日:

首先你必须设置范围来获取生日

signIn.scopes = ["me", "profile"]

let url : String = "https://www.googleapis.com/plus/v1/people/me"
    let request : NSMutableURLRequest = NSMutableURLRequest()
    request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
    request.URL = NSURL(string: url)
    request.HTTPMethod = "GET"
    print(request)
    NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue()) { (response : NSURLResponse?, data:NSData?, error:NSError?) -> Void in
        do
        {
            let jsonResult : NSDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
            print("Birthdate   : \(jsonResult.valueForKey("birthday"))")
        }
        catch
        {
            print(error)
        }
    }