diff --git a/report-issue/index.php b/report-issue/index.php index 9f89d04..bcf61c9 100644 --- a/report-issue/index.php +++ b/report-issue/index.php @@ -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 @@ +

You have submitted:

+

+