PHP Youdao translation api calling method example, PHP Youdao api example_PHP tutorial

WBOY
Release: 2016-07-13 10:11:07
Original
984 people have browsed it

php Youdao translation api calling method example, php Youdao api example

The example in this article describes the calling method of PHP Youdao Translation API. Here we use the file_get_contents function to directly read the data returned by the API for processing and share it with everyone for your reference. The specific analysis is as follows:

Before calling, we need to apply for a key for the Youdao Translation API data interface, the address is such as:

Copy code The code is as follows:
http://fanyi.youdao.com/openapi?path=data-mode

Method description, data interface:

Copy code The code is as follows:
http://fanyi.youdao.com/openapi.do?keyfrom=&key=< key>&type=data&doctype=&version=1.1&q=Text to be translated

Parameter description:

type - the type of the returned result, fixed to data

doctype - the data format of the returned result, xml or json or jsonp

version - version, the latest version is 1.1

q - The text to be translated cannot exceed 200 characters and needs to be encoded in UTF-8

errorCode:

0 - Normal

20 - The text to be translated is too long

30 - No valid translation possible

40 - Unsupported language type

50 - Invalid key

PHP example code is as follows:

Copy code 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 API key, the request frequency is limited to 1000 times per hour. If the limit is exceeded, you will be banned.

If your application does require more than 1,000 requests per hour, please contact translate-service@corp.youdao.com and provide the details of your application, name, function, website address, how to use the API, API key, expected access frequency, whether it is a commercial activity, screenshots, etc., as well as the server IP used by the application to access Youdao Translation API. Access restrictions can be relaxed after approval.

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/931547.htmlTechArticlephp Youdao translation api call method example, php Youdao api example This article tells the php Youdao translation api call Method, here we use the file_get_contents function to directly read the data returned by the api...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template