进入源代码/laravel-sportmonks-soccer

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

2.6.0 2024-09-11 12:21 UTC

This package is not auto-updated.

Last update: 2024-09-26 08:48:57 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下的特质中的调用。

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

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();