定制 agiledevelopment/url-shortener 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agiledevelopment/url-shortener

最新稳定版本:v1.0.3

Composer 安装命令:

composer require agiledevelopment/url-shortener

包简介

A robust PHP SDK for shortening URLs via the 00x.dk API

README 文档

README

A lightweight and robust PHP SDK for shortening URLs using the
00x.dk API.

🚀 Features

  • PHP 7.4+ compatible
  • PSR-4 autoloading
  • ✅ Input validation and robust error handling
  • ✅ Automatic retry logic on temporary API errors
  • ✅ Easy integration via Composer
  • ✅ Extensible for future endpoints (analytics, deletion, etc.)

📦 Installation

If you're using this SDK in a private project, add the Bitbucket repository to your composer.json file:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "git@bitbucket.org:csriraj/url-shortener-sdk.git"
    }
  ],
  "require": {
    "agiledevelopment/url-shortener": "^1.0"
  }
}

Then run the following command:

composer install

🧪 Usage Example

use AgileDevelopment\Shortener;

try {
    // Basic usage
    $result = Shortener::create('your_api_token', 'https://www.example.com');

    // Optional: specify a custom API base URL or origin domain
    // $result = Shortener::create(
    //     'your_api_token',
    //     'https://www.example.com',
    //     'https://staging.00x.dk/api/v1',
    //     'https://yourdomain.com'
    // );

    echo "Shortened URL: " . $result['shortened_url'];
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

⚙️ Method Reference

Shortener::create(string $token, string $url, ?string $baseUrl = null, ?string $origin = null): array

ParameterTypeRequiredDescription
$tokenstring✅ YesYour Bearer token from 00x.dk.
$urlstring✅ YesThe original URL you want to shorten.
$baseUrl?string❌ NoOptional custom API base URL. Defaults to https://00x.dk/api/v1.
$origin?string❌ NoOptional origin domain used for the Origin and Referer headers.

Returns:

[
  'shortened_url' => 'https://00x.dk/abcd1234'
]

Throws:

  • InvalidArgumentException if the input is invalid
  • RuntimeException if the API request fails after retries

🔐 API Requirements

Endpoint:

POST https://00x.dk/api/v1/urls

Headers:

Authorization: Bearer <your_token>
Content-Type: application/json
Accept: application/json

Body:

{
  "url": "https://bitbucket.org/csriraj/url-shortener-sdk"
}

Successful Response:

{
  "shortened_url": "https://00x.dk/00xdk",
  "original_url": "https://bitbucket.org/csriraj/url-shortener-sdk",
  "code": "00xdk",
  "message": "URL shortened successfully!"
}

📝 License

This project is licensed under the MIT License.

Made with ❤️ by **Agile Development**

统计信息

  • 总下载量: 177
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固