-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui_skriv.sms.php
51 lines (33 loc) · 1.12 KB
/
gui_skriv.sms.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
<div id="SMSVue">
</div>
<!-- TEMPORARY -->
<div style="margin-bottom: 500px;"></div>
<?php
use UKMNorge\OAuth2\HandleAPICall;
$handleCall = new HandleAPICall([], ['UKMSMS_recipients'], ['GET', 'POST'], false);
$mottakere = $handleCall->getOptionalArgument('UKMSMS_recipients');
// Remove the square brackets at the start and end of the string
$mottakere = trim($mottakere, "[]");
$recipients = array();
if(strlen($mottakere) > 0) {
// Split the string into individual recipient entries
$entries = explode('],[', $mottakere);
foreach ($entries as $entry) {
// Remove any remaining square brackets
$entry = trim($entry, '[]');
// Split the entry into number and name
list($number, $name) = explode(', ', $entry, 2);
// Trim any whitespace around the number and name
$number = trim($number);
$name = trim($name);
// Add the entry as an associative array to the recipients array
$recipients[] = array(
'mobil' => $number,
'name' => $name
);
}
}
// Add $mottakere to client side to be used by Vue
echo '<script>';
echo 'var alleMottakere = ' . json_encode($recipients) . ';';
echo '</script>';