加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swfit提交json.swfit post json.swfit提交header参数

发布时间:2020-12-15 20:04:57 所属栏目:百科 来源:网络整理
导读:使用Alamofire框架post json数据 ? func ? getappToken() - String { ? ? ? ? var path = "http://xxx.com/v1/app/token/request_token" ? ? ? ? let params: NSMutableDictionary = NSMutableDictionary () ? ? ? ? params[ "app_id" ] =? "56e6183b5610d74

使用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)

? ? ? ? }

?? ?

? ? }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读