topsort/sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

topsort/sdk

Composer 安装命令:

composer require topsort/sdk

包简介

Library for communicating with Topsort

README 文档

README

A PHP Software Development Kit for interacting with the auctions and events endpoints in the Topsort ecosystem.

Installation

The recommended way to install Topsort's SDK for PHP is with Composer. Composer is a dependency management tool for PHP that allows you to declare the dependencies your project needs and installs them into your project.

{
  "require": {
    "topsort/sdk": "3.0.1"
  }
}

Or with the command line:

composer require topsort/sdk

How it works

All operations are driven by our OpenAPI documentation, so all methods maps directly to the API description.

Usage: Running an auction

Topsort\SDK\SDK::auction requires three arguments:

  • slots: An array describing the product slots that are being auctioned.
  • products: An array, with the id's of the participating products.
  • session: An array, describing the user on the current session.
<?php
use Topsort\SDK;

$topsort_client = new SDK("my_api_key");

// An array of product IDs, each describing a product that should participate in
// the auction.
$products = [
    "i8bfHPJaxcAb3",
    "gDG0HV97ed2s"
];

// The Slots number specifies how many auctions winners should be returned for
// the auction.
$slots = 1;

// Run an auction.
$auction_result = $topsort_client->create_auction($slots, $products)->wait();

// => [
// "results" => [
//    [
//      "resultType" => "listings",
//      "winners" => [
//         [
//            "rank" => 1,
//            "type" => "product",
//            "id" => "gDG0HV97ed2s",
//            "resovedBidId" => "AKFU78"
//         ]
//      ]
//    ]
//  ]
//]

Usage: Reporting click events

Tracks whenever a product, promoted or not, had a click.

Topsort\SDK\SDK::report_click requires one argument, an array with the following keys:

  • entity: Required for unpromoted products. Must be the ID for the product that was clicked.
  • resolvedBidId: Required for promoted products. Must be the ID for the auction the product won.
  • placement: Optional. An array describing the placement of the product on the site.
  • id: Optional. The marketplace's ID for the event. If present, it should be unique. Topsort may use this field to de-duplicate events.
  • opaqueUserId: Optional. The marketplace's ID for the user. Defaults to a random UUID stored in a cookie.
  • occurredAt: Optional. A DateTime, from when the click happened. Defaults to the current time.
<?php

use Topsort\SDK;

$topsort_client = new SDK('my_api_key');

$placement = [
  // A marketplace assigned name for a page.
  "path" => "/categories/shoes",
];

// Report the click
$topsort_client->report_click([
  "placement" => $placement,
  "resolvedBidId" => "AKFU78",
]);

Usage: Reporting impression events

Tracks the product impressions on the site, and if any auction winners were rendered on the site.

Topsort\SDK\SDK::report_impressions requires one argument, an array with the following keys:

  • entity: Required for unpromoted products. Must be the ID for the product that was rendered.
  • resolvedBidId: Required for promoted products. Must be the ID for the auction the product won.
  • placement: Optional. An array describing the placement of the product on the site.
  • id: Optional. The marketplace's ID for the event. If present, it should be unique. Topsort may use this field to de-duplicate events.
  • opaqueUserId: Optional. The marketplace's ID for the user. Defaults to a random UUID stored in a cookie.
  • occurredAt: Optional. A DateTime, from when the impression happened. Defaults to the current time.
<?php

use Topsort\SDK;

$topsort_client = new SDK('my_marketplace', 'my_api_key');

$impression = [
  "placement" => [
    "path" => "/categories/shoes",
  ],
  "resolvedBidId" => "AKFU78",
];

// Report the impressions
$topsort_client->report_impression($impression);

Usage: Reporting purchases events

Topsort\SDK\SDK::report_purchase requires one argument, an array with the following keys:

  • items: An array of product data.
  • opaqueUserId: Optional. The marketplace's ID for the user. Defaults to a random UUID stored in a cookie.
  • occurredAt: Optional. A DateTime, from when the purchase happened. Defaults to the current time.
<?php

use Topsort\SDK;

$topsort_client = new SDK('my_api_key');

$items = [
  [
    "productId" => "gDG0HV97ed2s",
    "quantity" => 2,
    "unitPrice" => 10000,
  ]
];

// Report the purchase
$topsort_client->report_purchase([
  "occurredAt" => new DateTime(),
  "items" => $items,
]);

topsort/sdk 适用场景与选型建议

topsort/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 424 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 08 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ads」 「marketplace」 「promoted」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 topsort/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 topsort/sdk 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 14
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-31