Webhook Adapter

This adapter sends the message to a URL as a webhook using curl. Slack, Mattermost, and MS Teams (probably others) use the same format for incoming webhooks.

<?php
require './vendor/autoload.php';

use Vespula\Notifier\Notifier;
use Vespula\Notifier\Adapter\Webhook;

$url = 'https://some.server.com/webhooks/********';
$webhook = new Webhook($url);

$notifier = new Notifier();

$notifier->addAdapter('webook', $webhook);

$notifier->setMessage('my message');

$notifier->notify();

This will by default send a json payload of

1{
2    "text":"my message"
3}

If the text parameter is not text, you can modify it:

<?php
$webhook->setTextParam('someparam');

Which would send a json payload of

1{
2    "someparam":"my message"
3}

You can also set additional parameters individually, or as a group.

<?php
$webhook->setParam('paramname', 'paramvalue');

$params = [
    'name'=>'value',
    'foo'=>'bar'
];

$webhook->setParams($params);

You cannot set the text param as part of the setParam() or setParams() methods. If you do, it will be overwritten by the explicitly set text parameter.

These parameters make up the request JSON payload.