erster versuch
This commit is contained in:
58
troy-api.php
58
troy-api.php
@@ -1,16 +1,50 @@
|
||||
<?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 );
|
||||
$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 troysIssue($ident, $typ, $text = null, $data = [], $reaction = [], $wait_til = null) {
|
||||
global $sql;
|
||||
$url = "https://issues.troy-grunt.de/api/input";
|
||||
|
||||
$payload = [
|
||||
"domain" => $sql->issuedata['domain'],
|
||||
"secret" => $sql->issuedata['secret'],
|
||||
"ident" => $ident,
|
||||
"typ" => $typ,
|
||||
"text" => $text,
|
||||
"data" => $data,
|
||||
"reaction" => $reaction
|
||||
];
|
||||
|
||||
// Entferne null-Werte aus dem Array
|
||||
$payload = array_filter($payload, function ($value) {
|
||||
return $value !== null;
|
||||
});
|
||||
|
||||
$options = [
|
||||
"http" => [
|
||||
"header" => "Content-Type: application/json\r\n",
|
||||
"method" => "POST",
|
||||
"content" => json_encode($payload),
|
||||
"ignore_errors" => true
|
||||
]
|
||||
];
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$result = file_get_contents($url, false, $context);
|
||||
|
||||
return json_decode($result, true);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user