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