27 lines
		
	
	
		
			618 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			618 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
namespace App\Ntfy;
 | 
						|
 | 
						|
class Ntfy
 | 
						|
{
 | 
						|
    protected string $domain;
 | 
						|
    function __construct(string $domain)
 | 
						|
    {
 | 
						|
        $this->domain = $domain;
 | 
						|
    }
 | 
						|
 | 
						|
    function send(string $topic, string $title, string $message): void
 | 
						|
    {
 | 
						|
        file_get_contents(
 | 
						|
            'https://'.$this->domain.'/'.$topic, false, stream_context_create(
 | 
						|
                ['http' => [
 | 
						|
                'method' => 'POST', 
 | 
						|
                'header' =>
 | 
						|
                    "Content-Type: text/plain\r\n" .
 | 
						|
                    "Title: $title\r\n",
 | 
						|
                'content' => $message]
 | 
						|
                ]
 | 
						|
            )
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
} |