PHP code example of fanyigou / api-sdk-php

1. Go to this page and download the library: Download fanyigou/api-sdk-php 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/ */

    

fanyigou / api-sdk-php example snippets


composer 




Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$filePath = '文档路径'; //文档路径

$params = [
    'from' => 'en',
    'to' => 'zh',
];

try {
    $result = $dispatch->uploadTranslate($params, $filePath);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}