50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
function sendToTroy($data) {
|
|
$url = 'https://troy-grunt.de/api.php';
|
|
$options = array (
|
|
'http' => array (
|
|
'method' => 'POST',
|
|
'header' => array (
|
|
'Content-Type: application/json'
|
|
),
|
|
'content' => json_encode ( $data )
|
|
)
|
|
);
|
|
$context = stream_context_create ( $options );
|
|
return file_get_contents ( $url, false, $context );
|
|
}
|
|
|
|
function sendToGitea($title, $message) {
|
|
// secret.php liegt in lib/
|
|
require 'secret.php';
|
|
|
|
$url = rtrim($giteaUrl, '/') . "/repos/$giteaOwner/$giteaRepo/issues";
|
|
|
|
$data = [
|
|
"title" => $title,
|
|
"body" => $message
|
|
];
|
|
|
|
$options = [
|
|
'http' => [
|
|
'method' => 'POST',
|
|
'header' => [
|
|
"Content-Type: application/json",
|
|
"Authorization: token $giteaToken"
|
|
],
|
|
'content' => json_encode($data)
|
|
]
|
|
];
|
|
|
|
$context = stream_context_create($options);
|
|
$result = file_get_contents($url, false, $context);
|
|
|
|
if ($result === FALSE) {
|
|
throw new Exception("Fehler beim Erstellen der Anfrage");
|
|
}
|
|
|
|
return json_decode($result, true);
|
|
}
|
|
|
|
?>
|