-
Notifications
You must be signed in to change notification settings - Fork 0
PHP
PiotrFerenc edited this page May 14, 2024
·
1 revision
<?php
class Parameters {
public $ConsoleText;
public function __construct($consoleText) {
$this->ConsoleText = $consoleText;
}
}
class TaskItem {
public $Sequence;
public $Name;
public $Action;
public function __construct($sequence, $name, $action) {
$this->Sequence = $sequence;
$this->Name = $name;
$this->Action = $action;
}
}
class RequestPayload {
public $Parameters;
public $Tasks;
public function __construct($parameters, $tasks) {
$this->Parameters = $parameters;
$this->Tasks = $tasks;
}
}
function sendPostRequest($url, $payload) {
$jsonContent = json_encode($payload);
$options = [
'http' => [
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => $jsonContent,
],
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
echo "Error: " . $http_response_header[0];
} else {
echo "Response: " . $result;
}
}
$url = "http://localhost:5000/execute";
$parameters = new Parameters("hallo word");
$taskItem = new TaskItem(1, "log", "console");
$tasks = [$taskItem];
$payload = new RequestPayload($parameters, $tasks);
sendPostRequest($url, $payload);
?>