mlntn/fpl-api

梦幻英超联赛API

0.5.1 2014-07-07 16:14 UTC

This package is not auto-updated.

Last update: 2024-09-20 21:55:00 UTC


README

需要omni-cache

安装

使用composer

{
  "require": {
    "mlntn/fpl-api": "*",
    "mlntn/omni-cache": "*"
  },
  "minimum-stability": "dev",
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/mlntn/fpl-api"
    },
    {
      "type": "git",
      "url": "https://github.com/mlntn/omni-cache"
    }
  ]
}

编写控制器

<?php
$autoloader = require 'vendor/autoload.php';
$api = new Fpl\Api(new Cache\Provider\File('./cache', 86400));

$player = $api->getPlayer(323);
die(json_encode($player));

// prettier with this:
// json_encode($player, JSON_PRETTY_PRINT ^ JSON_UNESCAPED_UNICODE ^ JSON_UNESCAPED_SLASHES)

上面的代码做什么?

composer.json设置告诉Composer包含此API和由我编写的缓存工具omni-cache。

PHP控制器设置自动加载器,启动一个缓存处理器,将缓存保存到文件,最长为1天,启动API类(传递缓存处理器)并从fantasy.premierleague.com获取一些玩家数据(Artur Boruc)。

查看Fpl\Api.php以获取其他API方法。