短语/phrase-php

短语字符串API参考。短语字符串是一个软件项目的翻译管理平台。您可以使用团队协作进行语言文件翻译或通过我们的平台订购翻译。API允许您导入区域文件、下载区域文件、标记键或以其他方式与存储在短语字符串中的本地化数据交互。

2.4.0 2024-09-09 07:48 UTC

README

短语字符串是一个软件项目的翻译管理平台。您可以使用团队协作进行语言文件翻译或通过我们的平台订购翻译。API允许您导入区域文件、下载区域文件、标记键或以其他方式与存储在短语字符串中的本地化数据交互。

此PHP包由OpenAPI Generator项目自动生成

需求

PHP 5.5及更高版本

安装与使用

Composer

要从Composer安装绑定器,请从Packagist运行控制台

composer require phrase/phrase-php

如果您希望从Github存储库通过Composer安装绑定器,请将以下内容添加到composer.json

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/phrase/phrase-php.git"
    }
  ],
  "require": {
    "phrase/phrase-php": "*@dev"
  }
}

然后运行composer install

手动安装

下载文件并包含autoload.php

require_once('/path/to/phrase-php/vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门

请按照安装过程进行操作,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');


$config = Phrase\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY');
$config = Phrase\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token');

$apiInstance = new Phrase\Api\AccountsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$id = 'id_example'; // string | ID
$x_phrase_app_otp = 'x_phrase_app_otp_example'; // string | Two-Factor-Authentication token (optional)

try {
    $result = $apiInstance->accountShow($id, $x_phrase_app_otp);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AccountsApi->accountShow: ', $e->getMessage(), PHP_EOL;
}

?>

数据中心

API仅通过HTTPS访问,当前版本为v2,结果是一个类似于https://api.phrase.com/v2的基本URL,具体取决于数据中心。

欧盟数据中心

https://api.phrase.com/v2

这是默认的数据中心。

美国数据中心

https://api.us.app.phrase.com/v2/

指定美国数据中心

您可以通过以下设置使用美国数据中心

$config = Phrase\Configuration::getDefaultConfiguration()->setHost('https://api.us.app.phrase.com/v2/');

授权文档

令牌

  • 类型:API密钥
  • API密钥参数名:Authorization
  • 位置:HTTP头部
$config = Phrase\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY');
$config = Phrase\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token');

基本

  • 类型:HTTP基本身份验证
$config = Phrase\Configuration::getDefaultConfiguration()
              ->setUsername('YOUR_USERNAME')
              ->setPassword('YOUR_PASSWORD');

API端点文档

所有URI都是相对于https://api.phrase.com/v2

模型文档

作者

support@phrase.com

获取帮助/支持

请联系 support@phrase.com,我们可以采取更直接的行动来寻找解决方案。