Create submitToGitea(...) function

This commit is contained in:
Fred Boniface 2022-09-20 19:22:01 +01:00
parent 676dcfdc98
commit dc44deb343

View File

@ -1,3 +1,34 @@
THIS FILE WILL CONTAIN THE FUNCTIONS NEEDED TO SUBMIT AN ISSUE TO gitea <?php
TAKING IN ARGUMENTS CONTAINING THE REQUEST DATA function submitToGitea($title,$body) {
// Get API Key for git.fjla.uk
require '/srv/php-keys/athena/gitea.php';
// Set httpHeaders
$httpHeaders = array(
"accept: application/json",
$giteaKey,
"Content-Type: application/json"
);
// Prepare the request
$rawData = array(
'body' => $body,
'title' => $subject
);
$preparedData = json_encode($rawData);
// Prepare CURL
$curlConnection = curl_init('https://git.fjla.uk/api/v1/repos/fred.boniface/athena.fb-infra.uk/issues');
curl_setopt($curlConnection, CURLOPT_POSTFIELDS, $preparedData);
curl_setopt($curlConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlConnection, CURLOPT_HTTPHEADER, $httpHeaders);
// Get response and exit CURL
$response = curl_exec($curlConnection);
curl_close($curlConnection);
return $response;
}