vdhicts/hihaho-api-client
Composer 安装命令:
composer require vdhicts/hihaho-api-client
包简介
A client for the API of HiHaHo
README 文档
README
Easy HiHaHo REST API client.
Not all endpoints are currently implemented, feel free to add them or create an issue when you need help implementing the endpoint. It's also possible to extend the client.
Requirements
This package requires at least PHP 8.2.
Installation
This package can be used in any PHP project or with any framework.
You can install the package via composer:
composer require vdhicts/hihaho-api-client
Usage
This package is just an easy client for using the HiHaHo API. Please refer to the API documentation for more information about the requests.
Getting started
// Initialize the configuration $configuration = new \Vdhicts\HiHaHo\Configuration( .. ); // Initialize the API $api = new \Vdhicts\HiHaHo\HiHaHo($configuration); // Get all videos $response = $api->allVideos(); if ($response->ok()) { $response->json('data'); }
Authentication
This package will automatically retrieve the access token, so you won't have to store the access token. If you want to
store the access/refresh token anyway, you can access it in the Configuration class with:
$configuration->getAccessToken() or $configuration->getRefreshToken().
Extending the client
You can extend the client and implement your own endpoints:
class Video extends HiHaHo { public function updateVideo(int $videoId): Response { return $this ->withToken($this->getAccessToken()) ->put(sprintf('v2/video/%d', $videoId), [ 'status' => 0, ]); } }
Handling errors
A Response object will always be returned. See
Error handling of the Http Client.
if ($response->failed()) { var_dump($response->serverError()); }
Laravel
This package can be easily used in any Laravel application. I would suggest adding your credentials to the .env file
of the project:
HIHAHO_CLIENT_ID=clientid
HIHAHO_CLIENT_SECRET=secret
HIHAHO_USERNAME=username
HIHAHO_PASSWORD=password
Next create a config file hihaho.php in /config:
<?php return [ 'client_id' => env('HIHAHO_CLIENT_ID'), 'client_secret' => env('HIHAHO_CLIENT_SECRET'), 'username' => env('HIHAHO_USERNAME'), 'password' => env('HIHAHO_PASSWORD'), ];
And use those files to build the configuration:
$configuration = new Configuration( config('hihaho.client_id'), config('hihaho.client_secret'), config('hihaho.username'), config('hihaho.password'), );
In the future I might make a Laravel specific package which uses this package.
Tests
Unit tests are available in the tests folder. Run with:
composer test
When you want a code coverage report which will be generated in the build/report folder. Run with:
composer test-coverage
Contribution
Any contribution is welcome, but it should meet the PSR-12 standard and please create one pull request per feature/bug. 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 info@vdhicts.nl instead of using the issue tracker.
Support
This package isn't an official package from HiHaHo, so they probably won't offer support for it. If you encounter a problem with this client or has a question about it, feel free to open an issue on GitHub.
License
This package is open-sourced software licensed under the MIT license.
About Vdhicts
Vdhicts is the name of my personal company for which I work as freelancer. Vdhicts develops and implements IT solutions for businesses and educational institutions.
vdhicts/hihaho-api-client 适用场景与选型建议
vdhicts/hihaho-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.2k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 11 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「client」 「hihaho」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vdhicts/hihaho-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vdhicts/hihaho-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vdhicts/hihaho-api-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel JS Store - Easily render data to your blade templates to use in your frontend, like Vue
Hihaho Rector rules for auto-fixing code conventions
A PSR-7 compatible library for making CRUD API endpoints
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
统计信息
- 总下载量: 18.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-11-29