0

I wanna log in to this link My code is this

override func viewDidLoad() {
    super.viewDidLoad()

    let username = "14-032"
    let password = "choi3704"
    let loginParameters = ["id": username as String, "pwd": password as String]

    Alamofire.request(.POST, "http://students.ksa.hs.kr/scmanager/stuweb/index.jsp", parameters: loginParameters, encoding: .JSON).responseJSON{ response in switch response.result {
    case .Success(let JSON):
        let response = JSON as! NSDictionary
        print(response.objectForKey("type"))
    case .Failure(let error):
        print("Request failed with error, \(error)")
        }
    }
}

And I got

Request failed with error, Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 8." UserInfo={NSDebugDescription=Invalid value around character 8.}

How can I solve this problem?

김승수
  • 171
  • 2
  • 9

1 Answers1

0

Check my other answer to see how to scout the website for info. You didn't use the correct URL andyou don't the encoding: .JSON either.

Alamofire.request(.POST, "http://students.ksa.hs.kr/scmanager/stuweb/loginProc.jsp", parameters: loginParameters)
    .responseJSON{ response in
        switch response.result {
        case .Success(let JSON):
            let response = JSON as! NSDictionary
            print(response.objectForKey("type"))
        case .Failure(let error):
            print("Request failed with error, \(error)")
            }
    }

A couple other notes:

  • Please don't post real usernames and password to StackOverflow. There are bots that scan for these.
  • Your school uses unsecured HTTP for a login site. They are asking to be hacked.
Code Different
  • 90,614
  • 16
  • 144
  • 163