Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/devture/synology-chat

A library to communicate with the Synology Chat API
https://github.com/devture/synology-chat

Last synced: 13 days ago
JSON representation

A library to communicate with the Synology Chat API

Awesome Lists containing this project

README

        

# Synology Chat API

A library to communicate with the [Synology Chat API](https://www.synology.com/en-global/knowledgebase/DSM/help/Chat/chat_integration) (just Incoming Webhooks for now).

## Installation

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

## Usage

### Preparation
```php
$communicator = new \Devture\Component\SynologyChat\Communicator(new \GuzzleHttp\Client());
$client = new \Devture\Component\SynologyChat\Client($communicator);
```

### Actual usage
```php
$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.
}
```