danabrey/mfl-api
Composer 安装命令:
composer require danabrey/mfl-api
包简介
PHP library for interacting with the MyFantasyLeague.com API
README 文档
README
This is a PHP library for interacting with the MyFantasyLeague.com API. It's a work in progress, and I am actively developing it for use in other projects.
Installation
composer require danabrey/mfl-api
Usage
Create an instance of the client
$client = new DanAbrey\MFLApi\MFLApiClient(2020);
The league year is required. You can optionally pass an API key as the second argument for sending in all requests:
$client = new DanAbrey\MFLApi\MFLApiClient(2020, 'my_api_key');
Use the client methods to make requests to the API, e.g.:
$client->players()
$client->league('XXXXX') where XXXXX is the league ID.
$client->rosters('XXXXX') where XXXXX is the league ID.
All methods return either a single instance or an array of plain PHP objects that represent the data returned. e.g. MFLPlayer, MFLRoster[], etc.
Exception handling
The library throws a number of exceptions for you to decide how to handle yourself. They all extend the abstract DanAbrey\MFLApi\Exceptions\MFLApiException class.
UnauthorizedException: the API responded telling you that the endpoint needs an API key to access that data
InvalidParametersException: the API responded with an error hinting that you may have forgotten to pass a required parameter
UnknownApiError: the API responded with a 5xx HTTP error, usually this will mean there is an issue with the API at MFL's end
Note
It is your responsibility to abide by the terms of the MFL API.
Development
I am actively seeking contributors to this project. The MFL API is a complex and quite large beast, and accessing its data in projects can be a cumbersome task. This project aims to add reliable typing and understandable error handling via custom exceptions.
Please feel free to open an issue if you'd like to get involved.
Running tests
./vendor/bin/phpunit
Treeware
This package is MIT licensed and you are free to use it in open or closed source projects. If it makes it to your production environment, I would very much appreciate it if you bought the world some trees.
It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.
You can buy trees at offset.earth/treeware
Read more about Treeware at treeware.earth
danabrey/mfl-api 适用场景与选型建议
danabrey/mfl-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.07k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 06 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 danabrey/mfl-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 danabrey/mfl-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-29