statscore/apiclient

STATSCORE 官方 SportsAPI 客户端

v1.0.1 2020-04-14 16:44 UTC

README

Build Status Packagist codecov PHP from Travis config Quality Gate Status Libraries.io dependency status for GitHub repo

API 服务基于 REST 架构,支持使用 HTTP 协议访问的多种资源。客户端应发送 HTTP GET 请求,并将返回一个 JSON 或 XML 格式的列表文档。默认的响应格式是 JSON。

目录

安装

先决条件

文档

如何安装包

使用 Composer 通过以下命令安装最新版本:

$ composer require statscore/apiclient

或将其包添加到您的 composer.json 文件中。

{
  "require": {
    "statscore/apiclient": "^1"
  }
}

示例

认证

API 访问基于 oAuth 2.0 授权方法。这意味着使用唯一的令牌进行访问,没有 IP 限制。

客户端使用包含查询字符串参数的 GET 请求进行认证:client_id 和 secret_key。这些参数由我们的销售部门分配给您。在确认 client_id/secret_key 组合后,将返回特殊的 oAuth 令牌。令牌有效期的最大时间为从生成时间起的 24 小时。此令牌应随所有后续请求一起发送。

<?php
use Statscore\Client;
use Statscore\Model\Response\Authorization\AuthorizationDTO;

$clientId = 1;
$statscore = new Client($clientId, 'yoursecretkey');
/** @var AuthorizationDTO $authDTO */
$authDTO = $statscore->authorize();

/** Get your token, save it and use in future requests */
$statscore->setToken($authDTO->getToken());

已预订活动

获取所有

<?php
use Statscore\Model\Response\BookedEvent\BookedEventDTO;
use Statscore\Model\Response\ResponseDTO;

$clientId = 1;
$productName = 'livescorepro';

/** @var ResponseDTO $response */
$response = $statscore->bookedEvents->getAll($clientId, $productName);
/** @var BookedEventDTO[] $bookedEvents */
$bookedEvents = $response->getData();

创建

<?php
use Statscore\Model\Response\BookedEvent\BookedEventDTO;
use Statscore\Model\Response\ResponseDTO;

$clientId = 1;
$productName = 'livescorepro';
$eventId = 1232131;
/** @var ResponseDTO $response */
$response = $statscore->bookedEvents->create($clientId, $productName, $eventId);

/** @var BookedEventDTO[] $bookedEvents */
$bookedEvents = $response->getData();

删除

<?php
use Statscore\Model\Response\ResponseDTO;

$clientId = 1;
$productName = 'livescorepro';
$eventId = 1232131;
/** @var ResponseDTO $response */
$response = $statscore->bookedEvents->delete($clientId, $productName, $eventId);

故障排除

我们的支持团队位于卡托维兹,只有一个目的:服务于 STATSCORE 客户并使他们感到满意。

有问题吗?我们的团队将全天候、全年无休地帮助您找到答案。请发送电子邮件至 tech-support@statscore.com

问题在 GitHub 上跟踪