定制 codeswholesalev3/sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

codeswholesalev3/sdk

Composer 安装命令:

composer require codeswholesalev3/sdk

包简介

A PHP client library for CodesWholesale's API

README 文档

README


GitHub Issues PHP


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\Resource and CodesWholesale\Storage.
    • Client class handles all HTTP requests and authentication.
    • Fully object-oriented with typed properties and methods.
    • Exception handling for HTTP and authentication errors.

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 codeswholesalev3/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: CC-BY-NC-4.0
  • 更新时间: 2025-09-04