-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendvoice.php
45 lines (36 loc) · 1.09 KB
/
sendvoice.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
<?php
include(dirname(__FILE__)."/converter.class.php");
// 輸入 UTF-8 編碼的繁體中文
// 輸出 UTF-8 編碼且 URL Encode 的簡體中文
function nexmo_conv( $string )
{
$conv = new converter;
$string = $conv->convert('UTF','BIG', $string);
$string = $conv->convert('BIG','GB', $string);
$string = iconv('GBK', 'UTF-8//IGNORE', $string);
$string = urlencode($string);
return $string;
}
function sendvoicef($to , $text){
$url="https://rest.nexmo.com/tts/json?api_key="."641a3794"."&api_secret="."cba9477f"."&to=".$to."&text=".$text."&lg=zh-cn";
return (file_get_contents($url));
}
$file=fopen("sendlist","r");
while (!feof($file)) {
$str .= fgets($file);
}
fclose($file);
$sendlist=split(",\n", $str);
foreach($sendlist as $index => $to){
if($index!=0){
if(preg_match("/0([0-9]{9})/", $to, $matches)){
$to="+886".$matches[1];
}
if(preg_match("/(\+886[0-9]{9})/", $to, $matches)){
$to=$matches[1];
}
//$nexmo_sms->sendText( $to, $from, $sendlist[0] );
echo sendvoicef($to , nexmo_conv($sendlist[0]))."\n";
}
}
?>