-
Notifications
You must be signed in to change notification settings - Fork 0
/
ifttt-webhooks.php
119 lines (93 loc) · 2.24 KB
/
ifttt-webhooks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
include_once "/opt/fpp/www/common.php"; //Alows use of FPP Functions
include_once "iftttw-common.php";
if (strlen(urldecode($pluginSettings['ifttt_key']))<1){
WriteSettingToFile("ifttt_key",urlencode(""),$pluginName);
}
$iftttKey = urldecode($pluginSettings['ifttt_key']);
$isConfigured = false;
if (strlen($pluginSettings['ifttt_key']) > 0)
{
$isConfigured = true;
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="pluginBody" style="margin-left: 1em;">
<div class="title">
<h1>IFTTT Webhooks Settings</h1>
<h4></h4>
</div>
<p>Press F1 for setup instructions</p>
<table cellspacing="5">
<tr>
<th style="text-align: left">IFTTT Webhook Key</th>
<td>
<?
//function PrintSettingTextSaved($setting, $restart = 1, $reboot = 0, $maxlength = 32, $size = 32, $pluginName = "", $defaultValue = "", $callbackName = "", $changedFunction = "", $inputType = "text", $sData = Array())
PrintSettingTextSaved("ifttt_key", $restart = 0, $reboot = 0, $maxlength = 50, $size = 50, $pluginName = $pluginName, $defaultValue = "", $changedFunction = "keyChanged");
?>
</td>
</tr>
</table>
<br />
<br />
<hr />
<?
if ($isConfigured){
?>
<h3>Send Test Event</h3>
<div>
<table cellspacing="5">
<tbody>
<tr>
<th style="text-align: left">Event Name</th>
<td>
<input type="text" id="test_event_name" maxlength="50" size="50" value="lead_in">
</td>
</tr>
<tr>
<th style="text-align: left">Payload</th>
<td>
<select id="test_event_payload">
<?
$payloads = getPayloadOptions();
foreach($payloads as $item) {
$name = $item['name'];
echo '<option value="' . $name . '">' . $name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>
<button onclick="testButton();">Send Test Event</button>
</td>
</tr>
</tbody></table>
</div>
<?
}
?>
<script type="text/javascript">
function keyChanged(){
location.reload(true);
}
function testButton(){
ten = $('#test_event_name').val();
tep = $('#test_event_payload').val();
testExecute(ten, tep);
}
function testExecute(name, po){
url = '/api/command/' + encodeURIComponent('IFTTT Webhook Trigger') + '/' + encodeURIComponent(name) + '/' + encodeURIComponent(po);
$.get( url, function( data ) {
alert('Event fired. Check execute log for details.');
});
}
</script>
</body>
</html>