我是初学者,我无法弄清楚如何使用Alamofire制作.GET请求(但需要进行autenthication).我设法用其他Web服务(登录)执行此操作,因为它需要参数参数:
parameters = [
"username" : username
"password" : password
]
Run Code Online (Sandbox Code Playgroud)
然后:
Alamofire.request(.POST, loginUrl, parameters: parameters).responseJSON { (request, response, data, error) -> Void in
//handling the response
}
Run Code Online (Sandbox Code Playgroud)
在回复标题中我得到一些信息:
[Transfer-Encoding: Identity, Server: nginx/1.4.1, Content-Type: application/json, P3P: policyref="http://www.somewebpage.com", CP="NON DSP COR CURa TIA", Connection: keep-alive, Date: Sun, 08 Mar 2015 13:49:20 GMT, Vary: Accept-Encoding, Cookie, Set-Cookie: sessionid=5xeff47e65f674a4cc5b2d54f344304b; Domain=.somedomain.com; Path=/, tbauth=1; Domain=.somedomain.com; Path=/, Content-Encoding: gzip]
Run Code Online (Sandbox Code Playgroud)
这是类型 [NSObject : AnyObject]
如何将该信息存储在NSURLDefaults中并准备有效的请求参数(cookie)?我需要所有字段还是只需要Set-Cookie?
我试过手动设置参数:
parameters = [
"Cookie" : "sessionid=5xeff47e65f674a4cc5b2d54f344304b; Domain=.somedomain.com; Path=/, tbauth=1; Domain=.somedomain.com; Path=/" …Run Code Online (Sandbox Code Playgroud)