vdhicts/rebrandly-api-client
Composer 安装命令:
composer require vdhicts/rebrandly-api-client
包简介
API client for the API of Rebrandly
README 文档
README
Easily use the API of the url shortener Rebrandly.
Requirements
This packages requires PHP 7.4 or higher.
Installation
This package can be used in any PHP project or with any framework.
You can install the package via composer:
composer require vdhicts/rebrandly-api-client
Usage
This package tries to offer you a complete implementation of the Rebrandly API. Some endpoints are restricted to certain plans Rebrandly offer (like scripts and tags).
Quick usage
All endpoints can be retrieved from the Rebrandly class. This class needs the Client.
use Vdhicts\Rebrandly; // Initialize the client and the Rebrandly instance $client = new Rebrandly\Client('API_KEY'); $rebrandly = new Rebrandly\Rebrandly($client); // Access the endpoints $linksEndpoint = $rebrandly->links();
For example, to retrieve all links:
$links = $rebrandly->links()->list();
Options
Some endpoints of the Rebrandly API offer some filtering. Those filters can be set in the Options class. For example,
to order your links by clicks:
$links = $rebrandly->links()->list(new Options(['orderBy' => 'clicks', 'orderDir' => 'asc']));
Models
This client will always return the related models. When creating a new resource, the object is provided to the create
method. For example, to create a link:
$link = new Rebrandly\Models\Link(); $link->setDestination('https://time-tracker.vdhicts.nl'); $link->setSlashtag('time-tracker'); $link->setDomain($domain); $rebrandly->links()->create($link);
To create a link for you custom domain, you need to specify the domain in the Link model:
$domain = new Rebrandly\Models\Domain(); $domain->setFullName('yourdomain.tld'); $link->setDomain($domain); $rebrandly->links()->create($link);
Exceptions
When something goes wrong, the client will throw a RebrandlyException. If you want to catch exceptions from this
package, that's the one you should catch. Error responses from the API also result in the RebrandlyException.
Laravel
For Laravel users, I would suggest adding the api key to your .env file:
REBRANDLY_API_KEY="your-key"
And create a config file for Rebrandly or add this to your project's config file. Then initialize the client with the config value:
$client = new Rebrandly\Client(config('rebrandly.api_key'));
Tests
Unit tests are available in the tests folder. Run via phpunit:
vendor\bin\phpunit
By default a coverage report will be generated in the build/coverage folder.
Contribution
Any contribution is welcome, but it should meet the PSR-2 standard and please create one pull request per feature. In exchange you will be credited as contributor on this page.
Security
If you discover any security related issues in this or other packages of Vdhicts, please email security@vdhicts.nl instead of using the issue tracker.
License
This package is open-source software licensed under the MIT license.
Support
This package isn't an official package from Rebrandly, so they probably won't offer support for it. If you encounter a problem with this client, please open an issue on GitHub.
About vdhicts
Vdhicts is the name of my personal company. Vdhicts develops and implements IT solutions for businesses and educational institutions.
vdhicts/rebrandly-api-client 适用场景与选型建议
vdhicts/rebrandly-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.42k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vdhicts/rebrandly-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vdhicts/rebrandly-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-07