Php Youdao translation api call method

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.