PHP Youdao Translation API call method instance, PHP Youdao API Instance _php tutorial

Source: Internet
Author: User

PHP Youdao Translation API call method instance, PHP Youdao API instance


This article describes the PHP Youdao translation API call method, here we use the File_get_contents function directly read the data returned by the API for processing, share to everyone for your reference. The specific analysis is as follows:

Before calling we need to apply for a Youdao translation API data interface key, address such as:
Copy the Code code as follows: Http://fanyi.youdao.com/openapi?path=data-mode

Method description, Data interface:
Copy the Code code as follows: http://fanyi.youdao.com/openapi.do?keyfrom= &key= &type=data&doctype= &version=1.1&q= the text to be translated

Parameter description:

Type-Returns the types of results, fixed to data

DOCTYPE-Returns the data format of the result, either XML or JSON or JSONP

Version-versions, currently the latest version is 1.1

Q-The text to be translated, cannot exceed 200 characters, need to use UTF-8 encoding

ErrorCode:

0-Normal

20-The text to be translated is too long

30-Unable to translate effectively

40-Unsupported language type

50-Invalid Key

The PHP instance code is as follows:
Copy the Code code 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, and exceeding the limit will be blocked.

If your app does require more than 1000 requests per hour, contact translate-service@corp.youdao.com and provide details about your app, name, features, website address, how to use the API, API key, estimated frequency of access, Whether business behavior, screenshots, and so on, and the application to access the Youdao translation API used by the server IP, after approval can be relaxed access restrictions.

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/931547.html www.bkjia.com true http://www.bkjia.com/PHPjc/931547.html techarticle PHP Youdao Translation API call method instance, PHP Youdao API Example of this article describes the PHP Youdao translation API call method, here we take advantage of the file_get_contents function directly read the number returned by the API ...

  • 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.