Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. http://192.168.1.1/config.html
  2. <NSHTTPURLResponse: 0x14d21dd0> { URL: http://192.168.1.1/config.html }
  3. { status code: 200, headers {
  4. "Content-Type" = "text/html";
  5. Server = "WebServer V1.0";
  6. } }
  7.  
  8. func setPassword(){
  9. // Changed SSID, TYPE, & Password for example
  10. let body = "__SL_P_USD=SSID&__SL_P_USE=TYPE&__SL_P_USF=PASSWORD"
  11. let myURL = "http://192.168.1.1/config.html"
  12.  
  13. Alamofire.request(myURL, method: .post, parameters: [:], encoding: body, headers: [:]).responseJSON { response in
  14. print(response.request ?? "") // original URL request
  15. print(response.response ?? "") // HTTP URL response
  16. //print(response.data) // server data
  17. //print(response.result) // result of response serialization
  18.  
  19. if let JSON = response.result.value {
  20. print("JSON: (JSON)")
  21. }
  22. }
  23. }
  24.  
  25. extension String: ParameterEncoding {
  26.  
  27. public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
  28. var request = try urlRequest.asURLRequest()
  29. request.httpBody = data(using: .utf8, allowLossyConversion: false)
  30. return request
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement