Test of issue submission

This commit is contained in:
Fred Boniface 2022-09-17 20:57:03 +01:00
parent 80a52123d8
commit cd000594bc
1 changed files with 29 additions and 1 deletions

View File

@ -25,7 +25,32 @@
$subject = validate($_POST["subject"]);
$detail = validate($_POST["detail"]);
// ENTER CODE TO SUBMIT TO GITEA & DISPLAY SUCCESS MSG HERE
// Get API Key for git.fjla.uk
$giteaKey = file_get_contents('/srv/php-keys/athena/gitea');
// Set httpHeaders
$httpHeaders = array(
"accept: application/json",
$giteaKey,
"Content-Type: application/json"
)
// Prepare the request
$issueData = array(
'body' => $_POST["subject"],
'title' => $_POST["detail"],
'closed' => 'false'
)
// Prepare CURL
$curlConnection = curl_init('https://git.fjla.uk/api/v1/repos/fred.boniface/athena.fb-infra.uk/issues');
curl_setopt($curlConnection, CURLOPT_POSTFIELDS, $issueData);
curl_setopt($curlConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlConnection, CURLOPT_HTTPHEADER, $httpHeaders);
// Get response and exit CURL
$giteaResponse = curl_exec($curlConnection);
curl_close($curlConnection);
}
function validate($data) {
@ -66,6 +91,9 @@
<input type="submit">
</form>
<p>You have submitted:</p>
<p><?php echo $giteaResponse?>
<!-- Footer -->
<footer>
<p>Created by Fred Boniface - v0.4.0-devel</p>