fanyigou / api-sdk-php
翻译狗开放平台SDK-php
v1.0.1
2023-08-07 09:00 UTC
Requires
- php: >=7.1.0
- ext-curl: *
- ext-json: *
- php-curl-class/php-curl-class: ^9.14
- react/event-loop: ^1.3
- react/promise: ^2.9
- textalk/websocket: ^1.6
- workerman/workerman: ^4.1
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2025-03-29 01:06:30 UTC
README
环境说明
- PHP 7.1+
- cURL extension
操作步骤
- 使用Composer来管理项目依赖项,请在项目的根目录中运行以下命令:
composer require fanyigou/api-sdk-php
- 在Composer依赖管理器安装完成后,在您的PHP代码中导入该依赖项:
require_once __DIR__ . '/vendor/autoload.php';
示例代码
文件上传
<?php include_once __DIR__.'/vendor/autoload.php'; use 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()); }
更多示例/demo
License
- MIT