PHP: Send notifications

From Domoticz
Jump to: navigation, search


Easily send notifications of various types
The complete code is available at


Best combined with PHP: Store switch states and values in variables

Telegram Bot


function telegram($msg) {
  global $telegrambot,$telegramchatid;
  return $result;
telegram('This is a test message sent to Telegram bot at'.time());

Clickatell SMS

$smsuser='username';//Username at Clickatell
$smspassword='Xyz1234';//Password at Clickatell
$smsapi=1234567;//API code at Clickatell
$smstofrom=32479123456;//GSM Number used as sender/receiver of text messages
function sms($msg) {
sms('This is a test SMS');


Messages sent to iOS devices using the 'Find my iPhone' service off Apple. These type of messages always make sound, even when phone is on silent or do not disturb mode.
This function needs the findmyiphone.php file
Appledevice ID can be retrieved using findmyiphonedevices.php

$appleid='[email protected]';//AppleID email address
$applepass='Xyz_1234';//AppleID password
$appledevice='939FIdWFh845REeBs1nZk0sD/ZHxYptTlD4zoKvGC2VYH806kSRqROHYRNSUzmWV';//Apple device ID. 

function ios($msg) {
  global $appleid,$applepass,$appledevice;
  include ("findmyiphone.php");
  $fmi=new FindMyiPhone($appleid,$applepass);
ios('This is a test message');


See the pushover FAQ here:

function pushover($msg) {
    $url = "";
    $data = array(
       "token" => "[ Your Pushover Application Token ]",
       "user" => "[ Your Pushover User Token ]",
       "message" => $msg,
    $options = array(
       'http' => array(
           'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
           'method'  => 'POST',
           'content' => http_build_query($data),

    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);


See the Pushsafer HowTo here:

Pushsafer API description:

function pushsafer($m,$t,$s,$v,$i,$d,$u,$ut,$p,$l) {
    $url = '';
    $data = array(
    't' => urldecode($t),
    'm' => urldecode($m),
    's' => $s,
    'v' => $v,
    'i' => $i,
    'd' => $d,
    'u' => urldecode($u),
    'ut' => urldecode($ut),
    'l' => $l,
    'p' => $p,
    'k' => 'XXXXXXXXXXXXXXXXXXXX' // private or alias key
    $options = array(
        'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);

pushsafer('Message','Title','5','3','23','56','','Open Pushsafer','','0');