rebing/laravel-soccerama

Laravel 的 Soccerama 比分 API 调用封装 v2.0。rebing/laravel-soccerama 的分支

安装次数: 1,620

依赖者: 0

建议者: 0

安全: 0

星标: 12

关注者: 5

分支: 41

开放问题: 2

类型:项目

v1.0.2 2016-11-22 07:27 UTC

This package is auto-updated.

Last update: 2024-08-29 04:25:28 UTC


README

Laravel 的 Sportmonks (实时) 比分 API 调用封装。API 文档可以在 这里 找到

安装

1- 在您的 composer.json 文件中通过 Composer 需求此包。

{
  "require": {
    "kirill-latish/laravel-sportmonks-soccer": "^2.0"
  }
}

2- 运行 Composer 来安装或更新新需求。

$ composer install

$ composer update

3- 将服务提供者添加到您的 app/config/app.php 文件中

Sportmonks\SoccerAPI\SoccerAPIServiceProvider::class,

4- 将外观添加到您的 app/config/app.php 文件中

'SoccerAPI' => Sportmonks\SoccerAPI\Facades\SoccerAPI::class,

5- 发布配置文件

$ php artisan vendor:publish --provider="Sportmonks\SoccerAPI\SoccerAPIServiceProvider"

6- 检查配置文件并添加您的令牌(最好通过 env: 'api_token' => env('API_TOKEN')

config/soccerapi.php

7- 检查配置文件并添加您的时区(最好通过配置文件: 'timezone' => config('app.timezone')

config/soccerapi.php

使用方法

有关哪些调用可以执行的信息,请参阅官方 文档,并检查在 Sportmonks\SoccerAPI\Requests 下的 traits 中的调用。

例如,获取所有联赛(如果使用外观)

use SoccerAPI;

...

$response = SoccerAPI::leagues()->all();

上述代码返回一个包含 data 数组的对象。如果您想直接获取 data 中的数据,请更改您的配置文件: 'without_data' => true

通过其 ID 获取比赛

$response = SoccerAPI::fixtures()->byId($id);

如果您需要包含其他关系(请查看官方文档以确定可以包含哪些关系)

$include = 'league,fixtures';
// Or: $include = ['league', 'fixtures'];

$response = SoccerAPI::seasons()->setInclude($include)->all();