Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://192.168.1.1/config.html
- <NSHTTPURLResponse: 0x14d21dd0> { URL: http://192.168.1.1/config.html }
- { status code: 200, headers {
- "Content-Type" = "text/html";
- Server = "WebServer V1.0";
- } }
- func setPassword(){
- // Changed SSID, TYPE, & Password for example
- let body = "__SL_P_USD=SSID&__SL_P_USE=TYPE&__SL_P_USF=PASSWORD"
- let myURL = "http://192.168.1.1/config.html"
- Alamofire.request(myURL, method: .post, parameters: [:], encoding: body, headers: [:]).responseJSON { response in
- print(response.request ?? "") // original URL request
- print(response.response ?? "") // HTTP URL response
- //print(response.data) // server data
- //print(response.result) // result of response serialization
- if let JSON = response.result.value {
- print("JSON: (JSON)")
- }
- }
- }
- extension String: ParameterEncoding {
- public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
- var request = try urlRequest.asURLRequest()
- request.httpBody = data(using: .utf8, allowLossyConversion: false)
- return request
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement