我正在开发一个iOS应用程序,使用Deployd作为后端.The问题是,当我用sid向用户/我发送GET请求以标识我的会话时,它返回204--即使用户已登录,也没有内容。我期待一些数据作为回报。
Xcode控制台输出:
<NSHTTPURLResponse: 0x136ed2e00> { URL: http://xxxxxxxxxxxxxxx:2403/users/me?sid=3f53dd6c10...9fc4a00 } { status code: 204, headers {
"Cache-Control" = "no-cache, no-store, must-revalidate";
Connection = "keep-alive";
Date = "Sat, 16 Jan 2016 18:55:16 GMT";
Expires = 0;
Pragma = "no-cache"; } }发布于 2016-01-18 09:09:59
所以我把SID作为参数,这是不正确的。Deployd需要一个“障碍标记”。
Swift代码:
let url = NSURL(string: "http:/xxxxxxxxxxxxxxxx.com:2403/users/me")
let request = NSMutableURLRequest(URL: url!)
request.HTTPMethod = "GET"
request.setValue( "Bearer \(token!)", forHTTPHeaderField: "Authorization")
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.currentQueue()!) { response, maybeData, error in
if let data = maybeData {
let contents = NSString(data:data, encoding:NSUTF8StringEncoding)
print(contents!, "bitch")
} else {
print(error!.localizedDescription)
}
}https://stackoverflow.com/questions/34831030
复制相似问题