PHP code example of wangningkai / baidu-translation
1. Go to this page and download the library: Download wangningkai/baidu-translation library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wangningkai / baidu-translation example snippets
use WangNingkai\Translation\BaiduTranslation;
# $app_id = 您的ID;
# $secrect_key = 您的Key;
$translation = new BaiduTranslation($app_id,$secrect_key);
# $query 要查询的内容
# $from 源语言(见语言列表)
# $to 目标语言 (见语言列表)
$res = $translation->translate($query,$from,$to);