This article mainly introduces the php youdao translation api call method. The example analyzes the call methods and related skills of youdao translation API, which is very useful. For more information, see
This article mainly introduces the php youdao translation api call method. The example analyzes the call methods and related skills of youdao translation API, which is very useful. For more information, see
The example in this article describes the php youdao translation api call method. Here we use the file_get_contents function to directly read the data returned by the api for processing and share it with you for your reference. The specific analysis is as follows:
Before calling the API, we need to apply for a key to translate API data. The address is as follows:
The Code is as follows:
? Path = data-mode
Method description, data interface:
The Code is as follows:
? Keyfrom = & Key = & Amp; type = data & 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
The PHP instance code is as follows:
The Code is as follows:
$ 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 );
$ 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, please contact the translate-service@corp.youdao.com and provide your application details, name, function, website address, API method, API key, expected Access frequency, commercial behavior, screenshot, and so on, as well as the server IP Address used when the application accesses the youdao translation API, access restrictions can be relaxed after the review is passed.
I hope this article will help you with PHP programming.
,