codeswholesalev3/sdk
Composer 安装命令:
composer require codeswholesalev3/sdk
包简介
A PHP client library for CodesWholesale's API
README 文档
README
A simple and lightweight PHP SDK for interacting with the CodesWholesale API V3.
Designed in an object-oriented style inspired by the V2 SDK, with support for:
Features
-
Authentication & Token Management
- Automatic OAuth2 client credentials flow.
- Token storage via session or custom storage implementation.
- Automatic token renewal when expired.
-
Product Management
- Fetch all products with optional callback handling for large datasets.
- Retrieve specific products by ID.
- Access product codes (text or image) through structured objects.
-
Order Management
- Create new orders with multiple products.
- Retrieve orders and their status.
- Access ordered products as structured objects with codes.
-
Clean, Extensible Architecture
- Namespaced classes under
CodesWholesale\ResourceandCodesWholesale\Storage. - Client class handles all HTTP requests and authentication.
- Fully object-oriented with typed properties and methods.
- Exception handling for HTTP and authentication errors.
- Namespaced classes under
Requirements
- PHP 7.4+
- cURL extension enabled
Installation
composer require codeswholesalev3/sdk
Usage
1. Initialize the Client
use CodesWholesale\Client; use CodesWholesale\CodesWholesale; use CodesWholesale\Storage\SessionAuthTokenStorage; use CodesWholesale\Storage\FileContinuationTokenStorage; $params = [ 'cw.client_id' => 'your-client-id', 'cw.client_secret' => 'your-client-secret', 'cw.endpoint_uri' => CodesWholesale::SANDBOX_ENDPOINT, // or LIVE_ENDPOINT, 'cw.token_storage' => new SessionAuthTokenStorage() ]; $client = new Client($params); $continuationStorage = new FileContinuationTokenStorage(__DIR__ . '/last_token.txt'); $continuationToken = $continuationStorage->getContinuationToken();
2. Retrieve Products
use CodesWholesale\Resource\Product; use CodesWholesale\Resource\ProductItem; // Process all products page by page Product::getAll( $client, function (array $items, ?string $nextContinuationToken): void { foreach ($items as $item) { $product = new ProductItem($item); echo $product->getName() . PHP_EOL; } }, $continuationToken ); // Get a product by ID $product = Product::getById($client, 'PRODUCT_ID');
Getter list for products
$product->getName(); $product->getPrices(); $product->getDefaultPrice(); $product->getStock(); $product->getPlatform(); $product->getRegions(); $product->getReleaseDate();
3. Create an order
use CodesWholesale\Resource\Order; $createdOrder = Order::createOrder($client, [ ['productId' => '6313677f-5219-47e4-a067-7401f55c5a3a', 'quantity' => 2] ]);
4. Retrieve account details
use CodesWholesale\Resource\Account; $accountDetails = Account::getCurrent($client);
Getter list for the current account
$accountDetails->getBalance();
codeswholesalev3/sdk 适用场景与选型建议
codeswholesalev3/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「api」 「cloud」 「games」 「codeswholesale」 「cd-keys」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codeswholesalev3/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codeswholesalev3/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codeswholesalev3/sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
UCloud Resource (Cloud) Storage SDK for PHP
The flysystem adapter for yandex disk rest api.
Provide a way to secure accesses to all routes of an symfony application.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: CC-BY-NC-4.0
- 更新时间: 2025-09-04