gam6itko/ozon-seller
Composer 安装命令:
composer require gam6itko/ozon-seller
包简介
Ozon Seller Api for transhore sales
README 文档
README
Документация Ozon Api
https://docs.ozon.ru/api/seller
Установка
composer require gam6itko/ozon-seller
Для взаимодействия библиотеки с Ozon-Api нужно дополнительно установить реализации PSR-18: HTTP Client и PSR-17: HTTP Factories.
Использование с Symfony
https://symfony.com/doc/current/components/http_client.html#psr-18-and-psr-17
composer require symfony/http-client composer require nyholm/psr7
use Gam6itko\OzonSeller\Service\V1\ProductService; use Symfony\Component\HttpClient\Psr18Client; $config = [$_SERVER['CLIENT_ID'], $_SERVER['API_KEY'], $_SERVER['API_URL']]; $client = new Psr18Client(); $svc = new ProductService($config, $client); //do stuff
Использование без Symfony
composer require php-http/guzzle6-adapter
use Gam6itko\OzonSeller\Service\V1\CategoriesService; use GuzzleHttp\Client as GuzzleClient; use Http\Adapter\Guzzle6\Client as GuzzleAdapter; use Http\Factory\Guzzle\RequestFactory; use Http\Factory\Guzzle\StreamFactory; $config = [ 'clientId' => '<ozon seller client-id>', 'apiKey' => '<ozon seller api-key>', 'host' => 'http://cb-api.ozonru.me/' ]; $client = new GuzzleAdapter(new GuzzleClient()); $requestFactory = new RequestFactory(); $streamFactory = new StreamFactory(); $svc = new CategoriesService($config, $client, $requestFactory, $streamFactory); //do stuff
Реализованные методы
Чтобы узнать какой класс и метод реализуют запрос на нужный URL воспользуйтесь скриптом bin/is_realized.php
php bin/is_realized.php | grep /v2/posting/fbs/get
output
/v2/posting/fbs/get: Gam6itko\OzonSeller\Service\V2\Posting\FbsService::get /v2/posting/fbs/get-by-barcode: NotRealized
Автор не всегда успевает добавлять реализации новых методов. Если нужного вам метода нет в библиотеке, то не стесняйтесь открыть issue или PR.
Примеры использования
Больше примеров смотрите в папке tests/Service/
Categories
use Gam6itko\OzonSeller\Service\V1\CategoriesService; use GuzzleHttp\Client as GuzzleClient; use Http\Adapter\Guzzle6\Client as GuzzleAdapter; $config = [ 'clientId' => '<ozon seller client-id>', 'apiKey' => '<ozon seller api-key>', 'host' => 'http://cb-api.ozonru.me/' //sandbox ]; $adapter = new GuzzleAdapter(new GuzzleClient()); $svc = new CategoriesService($config, $adapter); //Server Response example: https://cb-api.ozonru.me/apiref/en/#t-title_categories $categoryTree = $svc->tree(); //Server Response example: https://cb-api.ozonru.me/apiref/en/#t-title_get_categories_attributes $attributes = $svc->attributes(17038826);
Posting Crossborder
get info
/v2/posting/crossborder/get
use Gam6itko\OzonSeller\Service\V2\Posting\CrossborderService; use GuzzleHttp\Client as GuzzleClient; use Http\Adapter\Guzzle6\Client as GuzzleAdapter; $config = [ 'clientId' => '<ozon seller client-id>', 'apiKey' => '<ozon seller api-key>', 'host' => 'http://cb-api.ozonru.me/' ]; $adapter = new GuzzleAdapter(new GuzzleClient()); $svc = new CrossborderService($config, $adapter); $postingNumber = '39268230-0002-3'; $orderArr = $svc->get($postingNumber); echo json_encode($orderArr);
{
"result": [
{
"address": {
"address_tail": "г. Москва, ул. Центральная, 1",
"addressee": "Петров Иван Владимирович",
"city": "Москва",
"comment": "",
"country": "Россия",
"district": "",
"phone": "+7 495 123-45-67",
"region": "Москва",
"zip_code": "101000"
},
"auto_cancel_date": "2019-11-18T11:30:11.571Z",
"cancel_reason_id": 76,
"created_at": "2019-11-18T11:30:11.571Z",
"customer_email": "petrov@email.com",
"customer_id": 60006,
"in_process_at": "2019-11-18T11:30:11.571Z",
"order_id": 77712345,
"order_nr": "1111444",
"posting_number": "39268230-0002-3",
"products": [
{
"name": "Фитнес-браслет",
"offer_id": "DEP-1234",
"price": "1900.00",
"quantity": 1,
"sku": 100056
}
],
"shipping_provider_id": 0,
"status": "awaiting_approve",
"tracking_number": ""
}
]
}
Products
import
/v1/product/import
use Gam6itko\OzonSeller\Service\V1\ProductService; use GuzzleHttp\Client as GuzzleClient; use Http\Adapter\Guzzle6\Client as GuzzleAdapter; $config = [ 'clientId' => '<ozon seller client-id>', 'apiKey' => '<ozon seller api-key>', // use prod host by default ]; $adapter = new GuzzleAdapter(new GuzzleClient()); $svcProduct = new ProductService($config, $adapter); $product = [ 'barcode' => '8801643566784', 'description' => 'Red Samsung Galaxy S9 with 512GB', 'category_id' => 17030819, 'name' => 'Samsung Galaxy S9', 'offer_id' => 'REDSGS9-512', 'price' => '79990', 'old_price' => '89990', 'premium_price' => '75555', 'vat' => '0', 'vendor' => 'Samsung', 'vendor_code' => 'SM-G960UZPAXAA', 'height' => 77, 'depth' => 11, 'width' => 120, 'dimension_unit' => 'mm', 'weight' => 120, 'weight_unit' => 'g', 'images' => [ [ 'file_name' => 'https://ozon-st.cdn.ngenix.net/multimedia/c1200/1022555115.jpg', 'default' => true, ], [ 'file_name' => 'https://ozon-st.cdn.ngenix.net/multimedia/c1200/1022555110.jpg', 'default' => false, ], [ 'file_name' => 'https://ozon-st.cdn.ngenix.net/multimedia/c1200/1022555111.jpg', 'default' => false, ], ], 'attributes' => [ [ 'id' => 8229, 'value' => '4747', ], [ 'id' => 9048, 'value' => 'Samsung Galaxy S9', ], [ 'id' => 4742, 'value' => '512 ГБ', ], [ 'id' => 4413, 'collection' => ['1', '2', '13'], ], [ 'id' => 4018, 'complex_collection' => [ [ 'collection' => [ [ 'id' => 4068, 'value' => 'Additional video', ], [ 'id' => 4074, 'value' => '5_-NKRVn7IQ', ], ], ], [ 'collection' => [ [ 'id' => 4068, 'value' => 'Another one video', ], [ 'id' => 4074, 'value' => '5_-NKRVn7IQ', ], ], ], ], ], ], ]; $svcProduct->import($product); // or $svcProduct->import([$product, $product1, $product2, ...]); // or $res = $svcProduct->import(['items' => [$product, $product1, $product2, ...] ]); echo $res['task_id']; // save it for checking by `importInfo`
gam6itko/ozon-seller 适用场景与选型建议
gam6itko/ozon-seller 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47.43k 次下载、GitHub Stars 达 116, 最近一次更新时间为 2019 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「marketplace」 「seller」 「Russia」 「ozon」 「crossborder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gam6itko/ozon-seller 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gam6itko/ozon-seller 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gam6itko/ozon-seller 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Automatically translate and review your content via Lokalise.
Ozon Seller Api for transhore sales (fork gam6itko/ozon-seller)
SDK de integração com a API de pagamentos da Braspag
Cliente em PHP para integração server-side com APIs Moip v2
Custom classified-ads composer, OLX-style listing pages and per-tag classifieds support for Flarum.
统计信息
- 总下载量: 47.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 116
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-07