支持 zh-汉语 en-英语 ja-日语 ko-韩语 fr-法语 ru-俄语 de-德语 互译
协议:HTTPS/POST
类型:application/json
地址:https://translate.lyfdev.com/translate
请求体:
{ "userid": "用户唯一ID", //向微信公众号 “星若生辉” 回复字母 t 申请 "content": "源文本", "source": "auto", //固定值(程序会自动识别提交过来语言) "target": "zh", //目标语言 枚举值:zh-汉语 en-英语 ja-日语 ko-韩语 fr-法语 ru-俄语 de-德语(若想翻译更多语言请咨询下面QQ) }响应体:
{ "code": 1, //1-成功 2-失败 "msg": "描述", "data": "翻译后的文本" }
PHP示例代码
<?php $url = 'https://translate.lyfdev.com/translate'; $postData = json_encode([ 'userid' => '向微信公众号 “星若生辉” 回复字母 t 申请', 'content' => '桌子上一只猫', 'target' => 'en', ]); $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData, CURLOPT_HTTPHEADER => [ 'Accept: application/json', 'Content-Type: application/json' ], CURLOPT_TIMEOUT => 60, CURLOPT_RETURNTRANSFER => true ]); $response = curl_exec($ch); $result = json_decode($response, true); print_r($result);Python示例代码
import requests url = 'https://translate.lyfdev.com/translate' payload = { 'userid': '向微信公众号 “星若生辉” 回复字母 t 申请', 'content': '桌子上面有一个苹果', 'target': 'en' } response = requests.post( url, json=payload, headers={ 'Accept': 'application/json', 'Content-Type': 'application/json' }, timeout=60 ) result = response.json() print(result)JavaScript示例代码
(async () => { const res = await fetch("https://translate.lyfdev.com/translate", { method: "POST", body: JSON.stringify({ content: "电脑桌上一个苹果", source: "auto", target: "en", userid: "向微信公众号 “星若生辉” 回复字母 t 申请'" }), headers: { "Content-Type": "application/json" } }); const content = await res.json() console.log(content); document.writeln(content.data) })();curl示例命令
curl -X POST "https://translate.lyfdev.com/translate" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ --max-time 60 \ -d "{\"userid\":\"向微信公众号 “星若生辉” 回复字母 t 申请\",\"content\":\"桌子上一只猫\",\"target\":\"en\"}"