swfit提交json.swfit post json.swfit提交header参数
使用Alamofire框架post json数据 ? func? getappToken() ->String { ? ? ? ? var path ="http://xxx.com/v1/app/token/request_token" ? ? ? ? let params:NSMutableDictionary =NSMutableDictionary() ? ? ? ? params["app_id"] =?"56e6183b5610d746578a9cf4" ? ? ? ? params["app_secret"] ="56e6183b2560ad79242a0ae4" ? ? ? ? params["mobile_id"] ="dfgdfgsdfgsdfgsdfg" ? ? ? ? var token:String? ="ss" ? ? ? ? Alamofire.request(.POST,path,parameters: paramsas! [String:AnyObject],encoding:.JSON) ? ? ? ? ? ? .responseJSON { responsein ? ? ? ? ? ? ? ? ? ? iflet JSON = response.result.value { ? ? ? ? ? ? ? ? ? ? ? ? var? datajosn:NSDictionary? = JSONas!NSDictionary ? ? ? ? ? ? ? ? ? ? ? ? var data:NSDictionary = datajosn["data"]?as!?NSDictionary ? ? ? ? ? ? ? ? ? ? ? ? ? token = data["token"]as!String ? ? ? ? ? ? ? ? ? ? ? ? self.login(token!); ? ? ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? return? token! ? ? } ?? ? ?? ? 使用Alamofire框架post header头字段 ? ? func login(apptoken:String) ? ? { ? ? ? ? var params:NSMutableDictionary =NSMutableDictionary() ? ? ? ? params["mobile_phone"] =self.phoneNumber.text ? ? ? ? params["password"] =self.passNumber.text ? ? ? ? var headparams:NSMutableDictionary =NSMutableDictionary() ? ? ? ? headparams["X-Ylwl-App-Token"] =? apptoken ? ? ? ? Alamofire.request(.POST,"http://xxxx.com/v1/app/users/login",parameters: paramsas? [String:AnyObject],encoding: .JSON,headers: headparamsas! [String :String]).responseJSON { (responSEObject)in ? ? ? ? ? ? print(responSEObject.result.value) ? ? ? ? } ?? ? ? ? } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |