swiped/handbal-webservice-api

Handbal Webservice API

v0.3.1 2018-09-06 13:09 UTC

This package is auto-updated.

Last update: 2024-09-07 05:32:14 UTC


README

此项目是从 fruitcakestudio/knkv-webservice-api 分支出来的。

使用 Composer 安装此包 ("swiped/handbal-webservice-api") 并要求自动加载器。

您可以直接使用 HttpClient 向 API 发送请求,或使用 API 对象获取更抽象的结果。

所有对象都有公共属性,与 API 中的键/值匹配。getProgam、getResults 和 getStandings 可以直接在 API 上调用,或在团队上调用。然后自动传递 Team ID。

请参阅http://www.onswebbond.nl/userfiles/knkv/webservice.zip上的文档。

您需要订阅 Onsweb Clubplugin for Handbal: http://www.onswebbond.nl/

注意:API每小时限制唯一的请求数量为1。请参阅下方的缓存使用说明。

注意:getResults上的page参数似乎还没有生效。

简单示例

require_once __DIR__ .'/../vendor/autoload.php';

use Swiped\HandbalWebservice\Api;

// Create a new API instance
$api = new Api($code);

$program = $api->getProgram(true);

foreach($api->getTeams() as $team){
    echo $team->getName();
    $results = $team->getResults();

    foreach($team->getStandings() as $standing){
        echo $standing->poule->getName();
        foreach ($standing->lines as $line) {
            echo $line->position .'. ' . $line->team_name;
        }
    }
}

缓存

您可以使用 Laravel 的缓存组件(illuminate/cache)。默认情况下,使用 ArrayCache 进行缓存,它只为当前请求进行缓存。如果您想使用 FileCache,例如,请使用 composer require "illuminate/filesystem": "~4.0"并执行以下操作

$filesystem = new \Illuminate\Filesystem\Filesystem;
$cacheStore = new \Illuminate\Cache\FileStore($filesystem, __DIR__.'/cache');

// Create a new API instance
$api = new Api($code, $cacheStore);

在 Laravel 中使用时,您可以使用Cache::getStore()获取缓存存储。