-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
61 lines (51 loc) · 1.21 KB
/
index.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
<?php
//By Shunxian Wu
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
//subscription infomation
$key = ''; //Default subscription key
$region = ''; //Default subscription region
//require('./subscription.php'); //this file can define $key and $region
//set param
if (isset($_GET['type'])) $data_type = $_GET['type'];
else $data_type = 'xml';
if (isset($_GET['key'])) $key = $_GET['key'];
if (isset($_GET['region'])) $region = $_GET['region'];
if (empty($key) || empty($region)) {
echo 'Error: Subscription error';
exit();
}
//get post data
$raw_data = file_get_contents('php://input');
if (empty($raw_data)) {
echo "Error: Empty data";
exit();
}
require('./xml.php');
//convert data
switch ($data_type) {
case 'json':
$data = build_mstts_xml(json_decode($raw_data,true));
if (empty($data)) {
echo 'Error: JSON Data Error';
exit();
}
break;
case 'xml':
$data = $raw_data;
break;
default:
echo "Error: Unknown data type";
exit();
}
require('./tts.php');
$return_xml = true;
$dt = get_audio($region,get_token($region,$key),$data, function ($c,$d) {
global $return_xml;
echo $d;
$return_xml = false;
return strlen($d);
});
if ($return_xml) echo $data;
?>