PHP code example of pbergman / ntfy-php

1. Go to this page and download the library: Download pbergman/ntfy-php 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/ */

    

pbergman / ntfy-php example snippets

injectablephp
use PBergman\Ntfy\Model\PublishParameters;
use PBergman\Ntfy\Model\HttpAction;

if (false !== $body = file_get_contents('out.txt')) {
    
    $message = new PublishParameters('Hello world test!!!', 'Test title');
    $message->setFilename('out.txt')
    $message->setTags(['foo', 'bar']);
    $message->addAction(new HttpAction('Google', 'https://google.nl'));
    
    $client->publish('test', $message, $body);
}
injectablephp
use PBergman\Ntfy\Model\SubscribeParameters;

$params = new SubscribeParameters();
$params->setSince('XXXXXXXXXX');
$params->setPoll(true);

$messages = \iterator_to_array($client->subscribe('test', $params));