hristonev/sportmonks-client-bundle

在 Symfony 中轻松与 SportMonks API 交流

1.0.3 2019-04-02 14:58 UTC

This package is not auto-updated.

Last update: 2024-09-19 18:08:07 UTC


README

Build Status

API 版本支持

此 API 客户端支持 SportMonks v2.0。

要求

  • PHP 5.6 或更高版本

安装

composer require hristonev/sportmonks-client-bundle

配置

// Bootstrap
require 'vendor/autoload.php';

use SportMonks\API\HTTPClient as SportMonksAPI;
use SportMonks\API\Utilities\Auth;

// Default values. Can be initialized without arguments.
$scheme = 'https';
$hostname = 'sportmonks.com';
$subDomain = 'soccer';
$port = 443;

// Auth.
$token = 'open sesame';

$client = new SportMonksAPI();
// or
//$client = new SportMonksAPI($scheme, $hostname, $subDomain, $port);

// Set auth.
$client->setAuth(Auth::BASIC, [
    'token' => $token
]);

使用示例

分页资源

$data = [];
do{
    $data = array_merge($data, $client->countries()->findAll());
}while($client->countries()->nextPage());
print_r($data);

参考

包含数据

$seasonId = 6361;
$teamId = 85;
$client->squad()->getBySeasonAndTeam(
    $seasonId,
    $teamId,
    [
        'query' => [
            'include' => 'player,position'
        ]
    ]
)

在上面的示例中,将球员信息和球员位置信息包含到集合中。 查看更多查询参数。

基本方法 endpoints

基本方法 find({id}), findAll(), nextPage(). nextPage() 用于分页响应。

  • 大洲
  • 国家
  • 联赛
  • 赛季
    • find(id, true) 包含结果。
    • standings(season_id)
    • standingsLive(season_id)
    • topScorers(season_id)
  • fixtures
    • between()->period(from, to, teamId) from 和 to 是 DateTime 对象,teamId 是整数。TeamId 是可选的。
    • date()->day(date) 参数是 DateTime 对象。
    • commentaries(fixture_id)
    • videoHighlights(fixture_id)
    • tvStations(fixture_id)
    • odds(fixture_id)
    • oddsByBookmaker(fixture_id, bookmaker_id)
    • oddsByMarket(fixture_id, market_id)
    • oddsInPlay(fixture_id)
    • Fixtures 不支持 findAll 方法。
  • teams
    • find(id, true) 包含统计数据。
    • season(id) 通过赛季获取队伍。
    • Teams 不支持 findAll 方法。
  • head2Head
    • get(array) 数组必须包含 2 个元素(team1_id,team2_id)。
    • 没有其他方法。
  • 实时得分
    • today()
    • inPlay()
  • 精彩瞬间
    • 视频精彩瞬间不支持 find 方法。在 fixtures 中提供了额外的方法。
  • 场馆
    • 场馆不支持 findAll 方法。
  • 博彩商
  • 球员
    • Players 不支持 findAll 方法。
  • 队伍
    • getBySeasonAndTeam(season_id, team_id) 没有其他方法