urlr/urlr-php

URLR 的 PHP 客户端

2.3.0 2024-07-01 10:04 UTC

This package is auto-updated.

Last update: 2024-08-31 10:35:19 UTC


README

Packagist Version Packagist Downloads Packagist License

此 SDK 是使用 OpenAPI Generator 项目自动生成的。

  • API 版本:1.3
  • 包版本:2.3.0
  • 构建包:urlr/urlr-php

更多信息,请访问 https://urlr.me/en

安装 & 使用

要求

PHP 8.1 及以上。

Composer

您可以通过 Composer 安装绑定。运行以下命令

composer require urlr/urlr-php

手动安装

下载文件并包含 autoload.php

<?php
require_once('/path/to/URLR/vendor/autoload.php');

入门

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

<?php

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

// Access Tokens

$accessTokensApi = new URLR\Api\AccessTokensApi(
    // 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()
);
$accessTokensRequest = new \URLR\Model\AccessTokensRequest([
    'username' => '',
    'password' => '',
]); // \URLR\Model\AccessTokensRequest | Your credentials

try {
    $token = $accessTokensApi->createAccessToken($accessTokensRequest)->getToken();
} catch (Exception $e) {
    echo 'Exception when calling AccessTokensApi->createAccessToken: ', $e->getMessage(), PHP_EOL;
    exit;
}

$config = URLR\Configuration::getDefaultConfiguration()->setAccessToken($token);

// Link shortening

$linksApi = new URLR\Api\LinksApi(null, $config);

$createLinkRequest = new \URLR\Model\CreateLinkRequest([
    'url' => '',
    'teamId' => ''
]); // \URLR\Model\CreateLinkRequest | Infos of the link to shorten

try {
    $result = $apiInstance->createLink($createLinkRequest);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling LinksApi->createLink: ', $e->getMessage(), PHP_EOL;
}

完整的示例在此处可用

API 端点

所有 URI 都相对于 https://urlr.me/api/v1

模型

授权

bearerAuth

  • 类型:Bearer 身份验证 (JWT)

测试

要运行测试,请使用

composer install
vendor/bin/phpunit

获取帮助/支持

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