PHP code example of keboola / notification-api-php-client

1. Go to this page and download the library: Download keboola/notification-api-php-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

keboola / notification-api-php-client example snippets


use Keboola\NotificationClient\EventsClient;
use Keboola\NotificationClient\Requests\PostEvent\JobFailedEventData;
use Keboola\NotificationClient\Requests\PostEvent\JobData;
use Keboola\NotificationClient\Requests\Event;
use Psr\Log\NullLogger;

$client = new EventsClient(
    new NullLogger(),
    'http://notifications.connection.keboola.com/',
    'xxx-xxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
);
$client->postEvent(
    new Event(        
        new JobFailedEventData(
            '123',
            'My Project',
            'Job finished with error',
            new JobData('my-project', '123', 'http://someUrl', '2020-01-02', '2020-01-01', 'my-orchestration')
        )
    )
);

use Keboola\NotificationClient\ClientFactory;

$clientFactory = new ClientFactory('https://connection.keboola.com');
$clientFactory->getEventsClient('xxx-xxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
json 
    {
      "appId": "268a6f05-xxxxxxxxxxxxxxxxxxxxxxxxxxx", //-> TEST_AZURE_CLIENT_ID
      "displayName": "testing-notification-api-php-client",
      "name": "http://testing-notification-api-php-client",
      "password": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", //-> TEST_AZURE_CLIENT_SECRET
      "tenant": "9b85ee6f-xxxxxxxxxxxxxxxxxxxxxxxxxxx" //-> TEST_AZURE_TENANT_ID
    }