bitly-api/sdk
最新稳定版本:1.7.0
Composer 安装命令:
composer require bitly-api/sdk
包简介
PHP library for Bitly API.
README 文档
README
PHP library for Bitly. Code is generated using the OpenAPI spec. See the API reference.
Requirements
Version
PHP >=8.0
API Key
Generate an access token.
Install
Install the package with Composer:
composer require bitly-api/sdk
If you're missing a package providing psr/http-client-implementation:
composer require php-http/guzzle7-adapter
Add autoloading:
require_once 'vendor/autoload.php';
Usage
Instantiate the SDK:
use Bitly\Bitly; $bitly = new Bitly('YOUR_API_KEY'); $client = $bitly->client;
Convert a long URL to a Bitlink:
use Bitly\Bitly; use Bitly\Model\Shorten; $bitly = new Bitly('YOUR_API_KEY'); $shorten = new Shorten(); $shorten->setLongUrl('https://example.com/my-long-url'); $response = $bitly->client->createBitLink($shorten);
Handle an API error:
use Bitly\Bitly; $bitly = new Bitly('YOUR_API_KEY'); try { $bitly->client->getBitlink('http://bit.ly/2OUJim0'); } catch (Throwable $exception) { echo $exception->getMessage(); echo $exception->getCode(); }
Scripts
composer build
Generate the code:
composer build
composer clean
Delete the lib/ directory:
composer clean
composer test
Run the tests:
composer test
About This Package
This package is automatically generated by Jane.
统计信息
- 总下载量: 63
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-26