repat/plentymarkets-rest-client
Composer 安装命令:
composer require repat/plentymarkets-rest-client
包简介
REST Client for Plentymarkets
README 文档
README
This is a PHP package for Plentymarkets new REST API. The API is relatively new at time of writing (March 2017), so not everything might work correctly and this package might also be out of date at some point.
I'm not in anyway affiliated with Plentymarkets, nor do I get paid for this by anybody. As it says in the license, this software is 'as-is'. If you want/need more features, open a GitHub ticket or write a pull request. I'll do my best :) That said, I don't work for the company I developed this for anymore, so if you have any interest in becoming a contributor on this repo, let me know.
You can find the Plentymarkets documentation here:
Overview
- Functions for the 4 HTTP verbs: GET, POST, PUT, DELETE
- Automatic login and refresh if login is not valid anymore
- Simple one-time configuration with PHP array (will be saved serialized in a file)
- Functions return an associative array by default or raw data (e.g. for files)
- Handle rate limiting (thanks hepisec)
Installation
Available via composer on Packagist:
composer require repat/plentymarkets-rest-client
Usage
use repat\PlentymarketsRestClient\PlentymarketsRestClient; // path to store the configuration in $configFilePath = ".plentymarkets-rest-client.config.php"; // $config only has to be set once like this $config = [ "username" => "PM_USERNAME", "password" => "PM_PASSWORD", "url" => "https://www.plentymarkets-system.tld", ]; // Handle (Guzzle) Exceptions yourself - optional 3rd parameter $handleExceptions = PlentymarketsRestClient::HANDLE_EXCEPTIONS; // true $handleExceptions = PlentymarketsRestClient::DONT_HANDLE_EXCEPTIONS; // false (default) // Init $client = new PlentymarketsRestClient($configFilePath, $config, $handleExceptions); // After that just use it like so $client = new PlentymarketsRestClient($configFilePath);
It's possible to use the 4 HTTP verbs like this
$client->get($path, $parameterArray); $client->post($path, $parameterArray); $client->put($path, $parameterArray); $client->delete($path, $parameterArray); // $parameterArray has to be a PHP array. It will be transformed into JSON automatically in case // of POST, PUT and DELETE or into query parameters in case of GET. // You don't _have_ to specify it, it will then just be empty $parameterArray = [ "createdAtFrom" => "2016-10-24T13:33:23+02:00" ]; // $path is the path you find in the Plentymarkets documentation $path = "rest/orders/";
It's also possible to use the function like this. It gives you more freedom, since you can specify the method and the $parameters given are directly given to the Guzzle object.
$client->singleCall("GET", $guzzleParameterArray);
Raw Data
Some endpoints, such as /rest/bi/raw-data/file don't return JSON but a raw file. However, by default a single call tries to json_decode() the response. You can disable it by setting the $jsonDecodeEnabled flag to false.
$client->setJsonDecodeEnabled(PlentymarketsRestClient::JSON_DECODE_DISABLED);
Errors
- If there was an error with the call (=> guzzle throws an exception) all methods will return false, unless
$handleExceptionshas been set totrue, in which case the exception will be handed through - If the specified config file doesn't exist or doesn't include username / password / url, an exception will be thrown
TODO
- Refresh without new login but refresh-token
Dependencies
- https://packagist.org/packages/nesbot/carbon for date comparison
- https://packagist.org/packages/guzzlehttp/guzzle for HTTP calls.
License
- see LICENSE file
Changelog
- 0.1.16 Enable / Disable
json_decode()to allow for querying for raw files (thx dark-cms) - 0.1.15 Enable returning PDFs (thx ewaldmedia)
- 0.1.14 Add short period write limit reached error handling (thx resslinger)
- 0.1.13 Change from Laravels
str_containsto PHPsstripos()because it doesn't requireext-mbstring(thx DanMan) - 0.1.12 Remove
danielstjules/stringydependency, copy over Laravelsstr_containsinstead - 0.1.11 PHP 8 Support & wait in case of short period read limit reached error (thx fwehrhausen)
- 0.1.10 Allow dealing with Exceptions yourself by passing
trueas 3rd parameter - 0.1.9 Bugfix
isAccessTokenValid()(thx hochdruckspezialist) - 0.1.8 Update, so Carbon 2.0 can be used (thx stefnats)
- 0.1.7 Fix constructor according to README (thx daniel-mannheimer)
- 0.1.6 Support for HTTP
PATCH(thx hepisec) - 0.1.5 Remove check for
www.as it breaks subdomains (thx daniel-mannheimer) - 0.1.4 Automatic rate limiting (thx hepisec)
- 0.1.3 Fix PHP 7.2 dependency
- 0.1.2 Fix Carbon dependency
- 0.1.1 Update Guzzle for PHP 7.2
- 0.1 initial release
Contact
- Homepage: https://repat.de
- e-mail: repat@repat.de
- Twitter: @repat123
repat/plentymarkets-rest-client 适用场景与选型建议
repat/plentymarkets-rest-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.66k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2017 年 02 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rest」 「api」 「client」 「sdk」 「pm」 「Plentymarkets」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 repat/plentymarkets-rest-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 repat/plentymarkets-rest-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 repat/plentymarkets-rest-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
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.
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
统计信息
- 总下载量: 10.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-24