This repository has been archived on 2024-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
discord-questbook/Matterbridge.php

24 lines
670 B
PHP

<?php
class Matterbridge {
protected $connection;
public function __construct() {
$this->connection = new \GuzzleHttp\Client([
'base_uri' => $_ENV['MATTERBRIDGE_URL'],
]);
}
public function post($text, $username) {
$response = $this->connection->request('POST', '/api/message', [
'json' => [
'gateway' => $_ENV['MATTERBRIDGE_GATEWAY'],
'text' => $text,
'username' => $username
],
'stream' => true,
]);
$body = $response->getBody();
while (!$body->eof()) {
echo $body->read(1024);
}
}
}