-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsnom-xml-cli.php
More file actions
executable file
·83 lines (74 loc) · 1.94 KB
/
snom-xml-cli.php
File metadata and controls
executable file
·83 lines (74 loc) · 1.94 KB
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
#!/usr/bin/php
<?php
/**
* (c) 2017 Volker Kettenbach
*
* See LICENSE for license details
*
* Commandline tool for sending XML screens to Snom phones
* Tested on Snom 370 - use option "-l long" for this phone
* Tested on Snom 320 - use option "-l short" for this phone
*
**/
require_once('PhpSIP.class.php');
$options = getopt("l:d:n:c:e:");
if ( !isset($options['l']) | !isset($options['d']) | !isset($options['n']) | !isset($options['c']) | !isset($options['e'])) {
print_help_and_exit($argv);
}
if ( $options['l']!="long" & $options['l']!="short"){
print "Invalid option: ". $options['l'] ."\n";
print_help_and_exit($argv);
}
try
{
$api = new PhpSIP('');
#$api->setDebug(true);;
$api->addHeader('Asterisk PBX');
$api->addHeader('Event: xml');
$api->setMethod('NOTIFY');
$api->setFrom('sip:asterisk@asterisk.kettenbach-it.de');
$api->addHeader('Content-Type: application/snomxml');
$api->setUri("sip:".$options['d']);
if ($options['l'] == "long") {
$api->setBody('
<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneText>
<Title>Eingehender Anruf</Title>
<Text>
An: '. $options['e'] . '<br/>
Von: ' . $options['n'] . '<br/>
Nummer: ' . $options['c'] . '
</Text>
<SoftKeyItem>
<Name>F1</Name>
<Label>Clear</Name>
<Softkey>CANCEL</Softkey>
</SoftKeyItem>
</SnomIPPhoneText>
');
}
if ($options['l'] == "short") {
$api->setBody('
<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneText>
<Text>
Von: ' . $options['n'] .' ' . $options['c'] . '
</Text>
<SoftKeyItem>
<Name>F1</Name>
<Label>Clear</Name>
<Softkey>CANCEL</Softkey>
</SoftKeyItem>
</SnomIPPhoneText>
');
}
$res = $api->send();
echo "response: $res\n";
} catch (Exception $e) {
echo $e;
}
function print_help_and_exit($argv) {
print "Usage: $argv[0] -l <short|long> -d <destination-uri w/o sip> -n <name of caller> -c <callerid number> -e <extension called>";
exit;
}
?>