I'm trying to develop an app for my school's grade portal (Using the Home Access Center platform).
(Im a bit of a beginner so please excuse any lapses in the information I have provided and if you need to me to provide it, I will be active)
So far I've been able to send the request and receive a response in the form of a string through .responseString, and when I print the response I'm getting an HTML doc type with the login parameters near the bottom. I have gotten this far, but I'm not sure how to pass my user-inputted data to the correct location. (I know where the parameters are located, but don't know how to access them).
The HTML file output looks like this,
<div>
<label class="sg-logon-left" for="LogOnDetails_UserName">User Name:</label>
<input class="sg-logon-right" data-val="true" data-val-required="The User Name: field is required." id="LogOnDetails_UserName" name="LogOnDetails.UserName" type="text" value="" />
<span class="field-validation-valid sg-logon-validation" data-valmsg-for="LogOnDetails.UserName" data-valmsg-replace="true"></span>
</div>
(just a small chunk of the file)
I've tried passing multiple different combinations of the parameters using a dictionary, but none of them have actually made it to that location. This website uses a action form (I'm a beginner, so I'm not sure about different interactions with HTML elements), but this is what passes when I run my program
<form action="/HomeAccess/SessionReset?ReturnUrl=%2FHomeAccess%2FAccount%2FLogOn%3FReturnUrl%3D%252fhomeaccess%252f" method="post">
< div class="sg-container" id="SignInSectionContainer">
I will send my current Swift code if need be, but if you might have a solution, the website is https://hac.friscoisd.org/HomeAccess/Account/LogOn?ReturnUrl=%2fhomeaccess%2f and I'm using Alamofire and Xcode (latest versions)
I have looked extensively for a thread that might have my answer, but I'm unable to find anything besides information on how to parse HTML files. Thanks a ton for any help and please reroute me if this is a duplicate question.
Swift Code @IBAction func getLoginData(_ sender: Any) {
let username = Username.text!
let password = Password.text!
if (username != "" && password != "")
{
let params : [String : String] = ["name" : "LogOnDetails.UserName","type" : "text", "value" : username]
//Make database a choosable number parameter later
sendLoginRequest(url: HAC_URL, parameters: params)
}
else
{
errorOutput.text = "Invalid Login"
}
}
func sendLoginRequest(url: String, parameters : [String : String])
{
Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding()).responseString
{
response in
if response.result.isSuccess
{
self.errorOutput.text = "Success"
print(response.result.value!)
}
else if response.result.isFailure
{
self.errorOutput.text = "Connection Issues"
print(response.error.debugDescription)
}
else
{
self.errorOutput.text = "Program Failure"
}
}
}
Edit I need to input a user entered string into an HTML