fruitcakestudio/knkv-webservice-api

此包已被废弃且不再维护。未建议替代包。

KNKV Webservice API

v0.1.0 2014-12-30 14:45 UTC

This package is not auto-updated.

Last update: 2023-09-28 10:30:11 UTC


README

使用Composer安装此包 ("fruitcakestudio/knkv-webservice-api": "0.1.x@dev",) 并要求自动加载器。

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

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

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

您需要订阅KNKV的Onsweb Clubplugin服务: http://www.onswebbond.nl/

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

注意:getResults上的page参数似乎尚未工作。

简单示例

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

use KNKV\Webservice\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等,请执行以下操作:

$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()来获取缓存存储。