devture/synology-chat

A library to communicate with the Synology Chat API

dev-master 2021-07-21 06:40 UTC

This package is auto-updated.

Last update: 2024-12-21 14:27:32 UTC


README

A library to communicate with the Synology Chat API (just Incoming Webhooks for now).

Installation

Install through composer: composer require --dev devture/synology-chat

Usage

Preparation

$communicator = new \Devture\Component\SynologyChat\Communicator(new \GuzzleHttp\Client());
$client = new \Devture\Component\SynologyChat\Client($communicator);

Actual usage

$incomingWebhookUrl = 'https://chat.DOMAIN/chat/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=some-token';

try {
	$client->sendWebhookMessage($incomingWebhookUrl, 'Hello!');
} catch (\Devture\Component\SynologyChat\Exception\AuthFailure $e) {
	// Bad token. No such incoming webhook?
} catch (\Devture\Component\SynologyChat\Exception $e) {
	// Another error. Likely transient and can be retried.
}