<?php
|
include_once "/Common/CommFunc.php";
|
include_once "/Common/Logging.php";
|
|
header("Content-type: text/html; charset=utf-8");
|
|
// 讯飞翻译内部返回测试工具
|
// https://www.xfyun.cn/doc/nlp/xftrans/API.html
|
// 0 成功
|
// 401 缺少authorization参数 {“message”:”Unauthorized”} 检查是否有authorization参数,详情见authorization参数详细生成规则
|
// 401 签名参数解析失败 {“message”:”HMAC signature cannot be verified”} 检查签名的各个参数是否有缺失是否正确,特别确认下复制的api_key是否正确
|
// 401 签名校验失败 {“message”:”HMAC signature does not match”} 签名验证失败,可能原因有很多。
|
// 1. 检查api_key,api_secret 是否正确。
|
// 2.检查计算签名的参数host,date,request-line是否按照协议要求拼接。
|
// 3. 检查signature签名的base64长度是否正常(正常44个字节)。
|
// 403 时钟偏移校验失败 {“message”:”HMAC signature cannot be verified, a valid date or x-date header is required for HMAC Authentication”} 检查服务器时间是否标准,相差5分钟以上会报此错误
|
// 403 IP白名单校验失败 {"message":"Your IP address is not allowed"}
|
|
\Logging\CreateLogging("test.tsl.php");
|
\Logging\LogInfo("_GET: " . print_r($_GET, true));
|
\Logging\LogInfo("_POST: " . print_r($_POST, true));
|
|
$fromlang = "cn";
|
$tolang = "en";
|
// $srcText = "你好世界";
|
// $dstText = "Hello World";
|
$srcText = "恭喜<color=#109d06FF>%s0</color>成功";
|
$dstText = "Congratulations <color=#109d06FF>%s0</color>";
|
// 1.0
|
$dstText = "< color = # 109d06 > { 0 } </color > name, congratulations on < color = # 109d06FF >% s0 </color > success";
|
// 2.0
|
$dstText = "Name < color= # 109d06 > {0} </color >, congratulations < color= # 109d06FF >% s0 </color >";
|
|
$randNum = mt_rand(1, 100);
|
if ($randNum >= 90) {
|
\Logging\LogInfo("概率返回错误内容: randNum:" . $randNum);
|
$dstText = "Congratulations < color= # 109d06ff >% s0 </color > In the environmental protection activities, draw < a > < Word info=item ID=% s1/> showitem=% s1 </a > x% s2, and contribute another strength to the celestial world 100%%";
|
} else {
|
$dstText = "Congratulations < color= # 109d06ff >% s0 </color > In the environmental protection activities, draw < a > < Word info=item ID=% s1/> | showitem=% s1 </a > x% s2, and contribute another strength to the celestial world 100%%";
|
}
|
$dstText = "Congratulations < color= # 109d06ff >% s0 </color > In the environmental protection activities, draw < a > < Word info=item ID=% s1/> | showitem=% s1 </a > x% s2, and contribute another strength to the celestial world 100%%";
|
$dstText = "Talk to < color = # 109d02 > Ergou </color >, talk to < color = # 109d02 > Ergou </color >, and tell < color = # 109d03 > Zhang San </color > and < color = # 109d04 > Li Si </color >, Tomorrow < color = # 109d05 > Wang Wu </color > and < color = # 109d06 > Zhao Liu </color > will come over. Talk to 1rep0, talk to 2rep1, talk to 3rep2, talk to 4rep3, talk to 5rep4";
|
// 使用后可获得称号</r>获得属性</r><color=#31cefb>生命 +5000</r>攻击 +125</color></r></r>有效期:永久</r></r><color=#31cefb>获取途径:</color></r>上古战场累计击败1000人
|
$dstText = "Use to gain title</R> Gain attribute</R><color=#31cefb> Life + 5000</R> Attack + 125</color></R> Validity: Permanent</R><color=#31cefb> Access:</color></R> Defeat 1000 people in the ancient battlefield";
|
$dstText = "Each attack adds an additional 20% skill damage.";
|
// <color=#109d06FF><a>%s0|showplayer=%s1 servergroupid=%s6 level=%s7 name=%s0</a></color>在<Word info=Map ID=%s2 lineid=%s8/>和<color=#12a199ff><Word info=NPC ID=%s3/></color>大战三百回合,获得了极品<a><Word info=item ID=%s4/>|showitem=%s4 userdata=%s5</a>
|
$dstText = "<color = # 109d06FF> <a>% s0 | showplayer =% s1 servergroupid =% s6 level =% s7 name =% s 0 </a> </color> di <Word info = Map ID =% s2 Lineid =% s8/> dan <color = # 12a199ff> <Word info = NPC ID =% s3/> </color> melawan tiga ratus putaran, Mendapat yang terbaik <a> <Word info = item ID =% s4/> | showitem =% s4 userdata =% s5 </a>";
|
// 仙盟名称的字数不能超过%S0个中文或%S1个英文
|
$dstText = "The number of characters in the name of Xianmeng cannot exceed% S0 Chinese characters or% S1 English characters";
|
// 开启后获得:</r><color=#35e122>初级生命神兵石*24</r>高级生命神兵石*1</r></color></r></r><color=#31cefb>获取途径:</color></r>【仙玉商城】
|
$dstText = "Get after opening: </R > < color = # 35e122 > Primary Life Soldier Stone * 24 </R > Advanced Life Soldier Stone * 1 </R > </color > </R > </R > < color = # 31 cefb > Access: </color > </R > [Fairy Jade Mall]";
|
$dstText = 'After opening, you can get:</r><color=#35e122> primary life magic stone * 24</r> advanced life magic stone * 1</r></color></r><color=#31cefb> access:</color></r> "Xianyu Mall"';
|
$dstText = "Get after opening: rep0 < color = # 35e122 > Primary Life Soldier Stone * 24rep1 Advanced Life Soldier Stone * 1rep2 </color > rep3rep4 < color = # 31cefb > Access: </color > rep5 [Fairy Jade Mall]";
|
$dstText = '< label name= "chn0" > Go to join the alliance </label > Recruit people with lofty ideals from all over the world, and prove the way of cultivating immortals and living forever. rep0 established rep1 Immortal Alliance! < label name= "chn1" > Go to join </label > < label name= "chn2" > Go to join </label > < label name= "chn3" > Go to join </label > < label name= "chn4" > Go to join </label >';
|
|
// <color=#109d06FF>%S0</color> builds the <color=#ff6701FF> %S1</color> Immortal Alliance! <color=#109d06FF><a> Going to join|ApplyFairy=%S2</a></color>
|
$dstText = 'rep0 builds the rep1 Immortal Alliance! < label name= \\"chn0\\" > Going to join </label >';
|
$dstText = '< label name= \\"chn0\\" > Go to join the alliance </label > Recruit people with lofty ideals from all over the world, and prove the way of cultivating immortals and living forever. rep0 established rep1 Immortal Alliance! < label name= \\"chn1\\" > Go to join </label > < label name= \\"chn2\\" > Go to join </label > < label name= \\"chn3\\" > Go to join </label > < label name= \\"chn4\\" > Go to join </label >';
|
$dstText = 'Mount feast BOSS: < Word info=NPC ID=% s0/> Only% s1% health left. < label name= \\"chn0\\" > Go now </label >';
|
$dstText = '< label name= \\"chn0\\" > Run into the third floor of the Star Tower </label >';
|
$dstText = "%s0 mengaktifkan komposisi, < label name=' chn0 ' > level < /label > membuka komposisi sayap < label name=\\\" chn0 \\\" > level < /label >";
|
$dstText = "Setelah digunakan, Anda bisa mendapatkan judul rep0 untuk mendapatkan atribut rep1 < color = #ec4bf6 > Life + 7313rep2 attack + 183rep3PVT damage + 1% < /color > rep4rep5 Validitas: permanen rep6rep7 < label name = \\\"chn0\\\" > Dapatkan rute: < /label > rep8\\\" output aktif \\\"";
|
$dstText = "< label name=\\\"chn0\\\" > level < /label > dapat langsung ditingkatkan 1 tingkat sebelum digunakan, setelah digunakan untuk mendapatkan pengalaman upgrade yang telah diperbaiki menjadi: < label name=\\\"chn1\\\" > level < /label > setelah digunakan untuk: < label name=\\\"chn2\\\" > level < /label >";
|
$dstText = "Dapatkan < label name=\\\"chn0\\\" > Summer carnaval < /label > Fashion set: < label name=\\\"chn1\\\" > Summer carnaval: senjata * 1 < /label > rep0 < label name=\\\"chn2\\\" > Summer carnaval: deputi * 1 < /label > rep1 < label name=\\\"chn3\\\" > Summer carnaval: pakaian * 1 < /label >";
|
$dstText = "Buka untuk mendapatkan: rep1 probabilitas untuk mendapatkan peralatan binatang putih, peralatan binatang biru, kristal biru ditingkatkan rep2 dapat membuka rep0 kali per hari untuk mendapatkan rute: rep4 < color = # 03deff > \\\"Penglai Wonderland\\\" mengumpulkan peti harta karun kecil < /color > rep5 item berikut untuk berbagi penggunaan harian: rep6 {ShareNum}";
|
$dstText = '< label name= \\"chn1\\" > Task complete </label >';
|
$dstText = "< label name=\\\"chn0\\\" > 4 peralatan ditingkatkan ke < color=#109d06 > level 10 < /color > < /label > {on_kill_20501}/ 4";
|
$dstText = "O nível de 250 pode ser obtido com rep0 Xianyu e < label name = \\\"chn0\\\": o máximo de dois ou cinco </label >";
|
$dstText = "Подросток rep0-rep1 костюм";
|
$dstText = "ЗваниеRep0 получает атрибут rep1<color=#31cefb>бонус к атаке +0,2% бонус к жизни rep2 +0,2% бонус к защите rep3 +0,2%</color>rep4rep5Срок действия: постоянный";
|
$dstText = "(PVE) вызывает громы большого диапазона и наносит < color=#109d06FF > 10</color > монстрам вокруг себя < color=#109d06FF > 3</color > один урон, каждый раз нанося < color=#109d06FF > 150%</color > урон навыка (дополнительный < color=#109d06FF > 851</color > урон навыка для диких чудищ)";
|
$dstText = "Взмахивая небесным топором, в течение 3 секунд он наносит мишени диапазона < color=#109d06FF > 212,14%</color > урон в секунду, и мишень замедляется < color=#109d06FF > 20%</color >";
|
$dstText = "Взмахивая небесным топором, в течение 3 секунд он наносит мишени диапазона < color=#109d06FF > 212,14%</color > урон в секунду, и мишень замедляется < color=#109d06FF > 20%</color >";
|
$dstText = "Wear < color=#109d06FF > @ NeedCnt @ Piece< /color > Gas-Refining Orange";
|
$dstText = "<color=#35e122>Xianyu</color>: Moeda de circulação preciosa, você pode comprar itens no shopping";
|
$dstText = "<color=#35e122> Shenyu</color>: Moeda de circulação preciosa, você pode comprar itens no Shenyu Mall";
|
$dstText = "(Desbloqueio de nível < /0 >)";
|
$dstText = "Você compra < cor = # 109d06FF > </0> </color > Xianyu para comprar < color = # 109d06FF > 1 < color > vezes </1> rep0?";
|
$dstText = "Faça a si mesmo no estado <color=#109d06FF> invencível</color>, mas não pode atacar, lançar habilidades, etc., continuar <color=#109d06FF> 2</color> segundos, resfriamento por 140 segundos";
|
$dstText = "Division Passivo: (PVP) é fatal, exceto para matar, com a chance de < cor = # 109d06FF > 25% < /cor > não morrer e restaurar < cor = # 109d06FF > 30% < color > 180s de sangue, resfriamento";
|
$dstText = "a(PVE) Convoca uma ampla gama de incêndios, causando 3 danos a 10 monstros ao redor, causando 100% de dano de habilidade a cada vez (causando 0% de dano de habilidade adicional a monstros selvagens)";
|
|
$code = 0;
|
$message = "";
|
|
// $randNum = mt_rand(1, 100);
|
// if ($randNum >= 30) {
|
// \Logging\LogInfo("概率返回翻译失败: randNum:" . $randNum);
|
// $code = 401;
|
// }
|
|
$ret = array("code" => $code, "message" => $message);
|
if ($code === 0) {
|
$ret = array_merge($ret, array(
|
"sid" => "its....",
|
"data" => array(
|
"result" => array(
|
"from" => $fromlang,
|
"to" => $tolang,
|
"trans_result" => array(
|
"src" => $srcText,
|
"dst" => $dstText,
|
),
|
)
|
),
|
));
|
} elseif ($code === 401) {
|
$ret = array("code" => $code, "message" => "HMAC signature does not match");
|
} else {
|
$ret = array("code" => -1, "message" => "unknown");
|
}
|
// echo json_encode($ret);
|
echo \CommFunc\MyJson_encode($ret);
|