LAMETRIC PUSH NOTIFICATION PHP

Recently buy a LAMETRIC Time wich is great and very well designed.

Here is a php script to push notification on local network. Comming soon to my Github.

Thanks to Lametric API Documentation 

Thanks to Blog.ARUEHE.IO

 

Precision : Authorization is a base64 composition of « DEV:YourAPIKEY »  -> https://www.base64encode.org

 

<h2>LAMETRIC LOCAL PUSH NOTIFICATION v1.00</h2>
<?php
// K.BARRIER V1.0
// SAME NETWORK LAMETRIC NOTIFICATION PUSHER
// API LAMETRIC COMPATIBILITY : 1.7.5
// PLEASE READ : http://lametric-documentation.readthedocs.io/en/latest/reference-docs/device-notifications.html


$nb_cycle=3; // NB of time the message will be repeat or stay displayed
$icon_id="i2078"; // id icon prefixed by "i" -> https://developer.lametric.com/icons
$message="ALARME"; // MAX 6 char (with icon) for no scroll
$priority="info"; // info, warning, critical
$priority_icon="info"; // none, info, alert 
$sound = "notification"; // http://lametric-documentation.readthedocs.io/en/latest/reference-docs/device-notifications.html
$sound_repeat=1;

$url = "http://yourip:8080/api/v2/device/notifications";

$curl = curl_init();
 
$headers = array(
 "Accept: application/json",
 "Content-Type: application/json",
 "Authorization: Basic Base64(DEV:YOURAPIKEY)",
 "Cache-Control: no-cache", 
);
 
 $frames = array(
 "priority" => $priority,
 'icon_type' => $priority_icon,
 "model" => array(
 "cycles" => $nb_cycle,
 "frames" => array(
 array(
 "icon" => $icon_id,
 "text" => $message
 ) 
 ),
 "sound" => array ( 
 
 "category" => "notifications",
 "id" => $sound,
 "repeat" => $sound_repeat
 
 )
 )
);

echo "CALL : <br>".json_encode($frames);
echo "<br><br>";
 
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, $url); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($curl, CURLOPT_POST, 1); 
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($frames)); 
 
$response = curl_exec($curl);
 
echo "RESPONSE : <br>".$response;
curl_close($curl);

?>
  •  
  •  
  •