02-notify.php 729 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace phpnotify;
  3. /**
  4. * Load library.
  5. */
  6. require_once(dirname(__FILE__).'/../sources/phpnotify.php');
  7. function get_line(string $name): string {
  8. $content = file_get_contents(dirname(__FILE__).'/'.$name);
  9. $content = str_replace("\r", '', $content);
  10. $content = str_replace("\n", '', $content);
  11. return $content;
  12. }
  13. $TOKEN = get_line('.token');
  14. $URL = get_line('.url');
  15. $SUBJECT = get_line('.subject');
  16. $auth = new token_authorization($TOKEN);
  17. $subject = notifier::create($URL)->access_method($auth)->topic($SUBJECT);
  18. $subject
  19. ->new_notification('Sample content')
  20. ->title('Title of')
  21. ->click_url('https://cixoelectronic.pl')
  22. ->add_tag('file_folder')
  23. ->add_tag('microbe')
  24. ->priority(4)
  25. ->send(true);