cocochepeau/yourls-php-sdk
最新稳定版本:0.1.3
Composer 安装命令:
composer require cocochepeau/yourls-php-sdk
包简介
A PHP SDK for interacting with the YOURLS API, enabling URL shortening, expansion, and statistics retrieval.
README 文档
README
Installation
composer require cocochepeau/yourls-php-sdk
Example Usage
// Initialize the SDK $yourls = new \Cocochepeau\YourlsPhpSdk\YourlsSDK('http://sho.rt/yourls-api.php', 'your_username', 'your_password'); // Create a short URL try { $shortUrl = $yourls->createShortUrl('http://example.com', 'custom-keyword', 'Example Title'); echo "Short URL: $shortUrl\n"; } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } // Expand a short URL try { $longUrl = $yourls->expandShortUrl('custom-keyword'); echo "Long URL: $longUrl\n"; } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } // Get stats for a specific short URL try { $stats = $yourls->getUrlStats('custom-keyword'); print_r($stats); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } // Get global stats try { $dbStats = $yourls->getDbStats(); print_r($dbStats); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); }
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2024-08-27