forked from geki-yaba/FritzBoxPHP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
110 lines (85 loc) · 2.67 KB
/
index.php
File metadata and controls
110 lines (85 loc) · 2.67 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
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
<?php
declare(strict_types=1);
require_once './vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
use function FritzBox\getServiceData;
use function FritzBox\getStateVars;
use function FritzBox\soapCall;
use function FritzBox\soapClient;
use function FritzBox\getHTTPSContent;
require_once('fritzbox.php');
//user and password
//- user is optional for default setup; simply set any name
//- otherwise use FritzBox-User with read/write access
$user = getenv('FRITZBOX_USERNAME');
$pass = getenv('FRITZBOX_PASSWORD');
$host = getenv('FRITZBOX_HOST');
//fritz!box soap server
//$base_uri = "http://192.168.0.254:49000/tr64desc.xml";
$base_uri = 'https://192.168.0.254:49443';
//description of services
$desc = "tr64desc.xml";
//function signatures, variables and its data types
$scpd = "x_tamSCPD.xml";
$action = "GetList";
try
{
//receive service description
$service = getServiceData($base_uri, $desc, $scpd);
if ($service === false)
{
throw new \RuntimeException("no service found in ". $scpd);
}
#print_r($service);
//set user and password
$service['login'] = $user;
$service['password'] = $pass;
//receive variables and its data types belonging to action
/*
$stateVars = getStateVars($base_uri, $service, $action);
if ($stateVars === false)
{
throw new Exception("no state variables belonging to $action");
}
print_r($stateVars);exit;
*/
//create soap client
$client = soapClient($service);
//execute action published by service
//get global information and the specific answering machine
$list = soapCall($client, $action);
//echo $list;
$action = 'GetMessageList';
$listURL = soapCall($client, $action,
new SoapParam(1, 'NewIndex'));
$parts = parse_url($listURL);
parse_str($parts['query'], $query);
$sid = $query['sid'];
echo 'TAMList URL: ' . $listURL . PHP_EOL;
$TAMList = getHTTPSContent($listURL);
if (empty($TAMList)) {
throw new \RuntimeException('No messages found.');
}
echo "sid: " . $sid . PHP_EOL;
$xml = simplexml_load_string($TAMList);
if ($xml === false) {
echo 'Failed loading XML: ' . PHP_EOL;
foreach(libxml_get_errors() as $error) {
echo $error->message . PHP_EOL;
}
} else {
$i = 0;
foreach ($xml->Message as $message) {
$i++;
echo $message->Path . PHP_EOL;
$file = getHTTPSContent($base_uri . $message->Path . '&sid=' . $sid);
file_put_contents('file' . $i . '.wav', $file);
}
}
echo PHP_EOL;
}
catch(Exception $e)
{
echo $e->__toString() . PHP_EOL;
}