datana-gmbh/url-shortener-api

1.2.0 2023-10-06 11:31 UTC

This package is auto-updated.

Last update: 2024-08-30 00:20:34 UTC


README

用法

安装

composer require datana-gmbh/url-shortener-api

设置

use Datana\UrlShortener\Api\UrlShortenerClient;

$baseUri = 'https://url-shortner.datana.app';
$username = '...';
$password = '...';

$client = new UrlShortenerClient($baseUri, $username, $password);

生成短链接

use Datana\UrlShortener\Api\UrlShortenerApi;
use Datana\UrlShortener\Api\UrlShortenerClient;

$client = new UrlShortenerClient(/* ... */);

$api = new UrlShortenerApi($client);
$response = $api->generateShortUrl('https://www.google.com');

$response->getShortUrl(); // returns sth. like https://......./12DDFFS3