I need help working with the lansweeper API. This is an example of their API request
http://YourServerName:81/api.aspx?Action=AddTicket&Key=123456789&Subject=Example&Description=Example&Username=example&email=test@blah.com
I have a HTML form below with the required values I need the user to input. The method has to be Post.I'm having trouble determining next steps from here.
I tried using hidden fields to add the Action and the Key but that wasn't working how I pictured it because i'm not sure how to hide the value and the identifier for it. I tried changing the form action to a php file, saving the input into variables and then tried constructing the link in a very roundabout way (below) but I got stuck once again not certain of where to go next.
Any help/insight is highly appreciated.
<form action="http://lansweeper:81/api.aspx?" method="post">
<input type="hidden" name="Action" value="AddTicket">
<input type="hidden" name="Key" value="80aac06c-43c1-498a-9e0f-d477e398b13b">
<label>Subject: </label>
<input type="text"id="sub" name="Subject" required oninvalid="this.setCustomValidity('Name cannot be empty. Please enter your name')"
onchange="this.setCustomValidity('')">
<br>
<label>Description: </label>
<input type="text"id="descrip" name="Descrip" required oninvalid="this.setCustomValidity('Name cannot be empty. Please enter your name')"
onchange="this.setCustomValidity('')"><br>
<label>Username: </label>
<input type="text"id="username" name="Username" required oninvalid="this.setCustomValidity('Name cannot be empty. Please enter your name')"
onchange="this.setCustomValidity('')"><br>
<label>Email: </label>
<input type="text"id="email" name="Email" required oninvalid="this.setCustomValidity('Name cannot be empty. Please enter your name')"
onchange="this.setCustomValidity('')"><br>
<input type="submit">
</form>
PHP:
<?php
if (isset($_POST['submit'])){
$link = "http://lansweeper:81/api.aspx?Action=";
$sub = $_POST['subject'];
$descrip = $_GET['desctip'];
$user = $_POST['username'];
$mail = $_POST['email'];
$key = '123456789&';
$action = 'AddTicket&';
$link .= $action;
$link .= $key;
$link .= "Subject=";
$link .= $sub;
$link .= "&";
$link .= "Description=";
$link .= $descrip;
$link .= "&";
$link .= "Username=";
$link .= $user;
$link .= "&";
$link .= "Email=";
$link .= $mail;
echo $link;
}
?>
question from:
https://stackoverflow.com/questions/65909677/how-to-construct-url-for-api-request 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…