<?php
namespace App\Ntfy;

class Ntfy
{
    protected $domain;
    function __construct($domain)
    {
        $this->domain = $domain;
    }

    function send($topic,$title, $message)
    {
        file_get_contents(
            'https://'.$this->domain.'/'.$topic, false, stream_context_create(
                ['http' => [
                'method' => 'POST', 
                'header' => 'Content-Type: text/plain',
                'header' =>
                    "Content-Type: text/plain\r\n" .
                    "Title: $title\r\n",
                'content' => $message]
                ]
            )
        );
    }

}