kimai/api-php

为 Kimai 生成的 Swagger API 模板

1.0 2023-06-24 08:59 UTC

This package is auto-updated.

Last update: 2024-08-24 11:33:29 UTC


README

Kimai 时间跟踪软件的 JSON API: API 文档

此 PHP 包由 Swagger Codegen 项目自动生成

  • API 版本:0.7(适用于 Kimai 2.0.x)

要求

  • Kimai 2.0.x
  • PHP 7.4 及以上
  • Curl 扩展
  • JSON 扩展
  • mbstring 扩展

安装与使用

Composer

通过 Composer 安装绑定

composer require kimai/api-php

入门

请遵循 安装流程,然后运行以下命令

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

$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('X-AUTH-TOKEN', 'YOUR_API_KEY');
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('X-AUTH-USER', 'YOUR_USERNAME');

$apiInstance = new Swagger\Client\Api\ActivityApi(
    // 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
);
$project = "123"; // string | Project ID to filter activities
$projects = []; // string[] | List of project IDs to filter activities, e.g.: projects[]=1&projects[]=2
$visible = "1"; // string | Visibility status to filter activities: 1=visible, 2=hidden, 3=all
$globals = "1"; // string | Use if you want to fetch only global activities. Allowed values: true (default: false)
$order_by = "name"; // string | The field by which results will be ordered. Allowed values: id, name, project (default: name)
$order = "order_example"; // string | The result order. Allowed values: ASC, DESC (default: ASC)
$term = "term_example"; // string | Free search term

try {
    $result = $apiInstance->getGetActivities($project, $projects, $visible, $globals, $order_by, $order, $term);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ActivityApi->apiActivitiesGet: ', $e->getMessage(), PHP_EOL;
}