Before calling the API, we need to apply for a key to Translate API data. The address is as follows:
Http://fanyi.youdao.com/openapi? Path = data-mode
Method description, data interface
Http://fanyi.youdao.com/openapi.do? Keyfrom = <keyfrom> & key = <key> & type = data & doctype = <doctype> & version = 1.1 & q = text to be translated
Parameter description:
Type-type of the returned result, fixed to data
Doctype-data format of the returned results, xml, json, or jsonp
Version-version. The latest version is 1.1.
Q-the text to be translated cannot exceed 200 characters and must be UTF-8 encoded
ErrorCode:
0-normal
20-the text to be translated is too long
30-no valid translation is available
40-unsupported language types
50-invalid key
Example
| The code is as follows: |
Copy code |
|
$ Url = "http://fanyi.youdao.com/openapi.do? Keyfrom = xujiangtao & key = 1490852988 & type = data & doctype = json & version = 1.1 & q = ". $ content;
$ List = file_get_contents ($ url); www.111cn.net
$ Js_de = json_decode ($ list, true ); |
Note:
When using the API key, the request frequency is limited to 1000 times per hour. If the limit is exceeded, the request will be banned.
If your application does require more than 1000 requests per hour, contact your translate-service@corp.youdao.com. And provide detailed information about your application (name, function, website address, API usage method, API key, estimated access frequency, commercial behavior, screenshots, etc) and the server IP address used by the application to access the Youdao translation API. After the application is approved, the access restriction can be relaxed.