Download the PHP package christohill/cfl-api-php without Composer
On this page you can find all versions of the php package christohill/cfl-api-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download christohill/cfl-api-php
More information about christohill/cfl-api-php
Files in christohill/cfl-api-php
Package cfl-api-php
Short Description A PHP wrapper for the CFL.ca API
License MIT
Homepage https://github.com/christohill/cfl-api-php
Informations about the package cfl-api-php
CFL.ca API wrapper for PHP
This is a simple PHP SDK for interacting with the CFL API. All API documentation can be found at http://api.cfl.ca.
Installation
composer install christohill/cfl-api-php dev-master
Usage
Note: none of the API keys below are valid
You can request access to the API at api.cfl.ca/key-request
All endpoints in the API are mapped to their own methods in the wrapper. You can see all the folder full of examples to reference.
Simple usage
Setting API key
There are a few ways to set an API key.
- Set an .env variable (CFLPHP_Key):
CFLPHP_Key="edf59be9216e66eb17093574376d4c5f"
- Set as an argument to the constructor:
$teams = new Teams('edf59be9216e66eb17093574376d4c5f')
- Use
setKey
setter method after the class has been instantiated:
Request configuration
Most methods/endpoints accept some sort of configuration (include, sort, filter, pagination). Refer to method names below to see which accept these. These are set as a multidimensional array like this:
There is some special formatting for each config type:
Include
The API accepts comma separated values, so just a simple array will work for this:
Sort
The API accepts comma separated values, so just a simple array will work for this:
Note: Using - in front of the sort term will reverse the order
Filter
The API can accept multiple filters to try and narrow down the data you need. There is a slight change here from the original API to help keep these filters legible.
Instead of using the [property][operator] format, the wrapper uses simple strings with PHP style operators. The operators are as follows:
See how the operators work here
Pagination
Pagination is as simple as passing a page number and size to the config array.
Methods
Method | Description | Docs |
---|---|---|
getGames($season, $config) | Get a list of all games in a particular season | Read docs |
getSingleGame($season, $gameID, $config) | Get data for a specific game | Read docs |
getLeaders($season, $category, $config) | Get a list of leaders based on a statistical category | Read docs |
getTeamLeaders($season, $category, $config) | Get a list of team leaders based on a statistical category | Read docs |
getPlayers($config) | Get a list of all players | Read docs |
getSinglePlayer($player_id, $config) | Get all data for a specific player | Read docs |
getStandings($season) | Get the team standings for a given season | Read docs |
getCrossoverStandings($season) | Get the crossover team standings for a given season | Read docs |
getTeams | Get a list of all teams | Read docs |
getTeamByID($team_id) | Get a CFL team by unique ID | N/A |
getTeamByAbbr($abbreviation) | Get a CFL team by team abbreviation | N/A |
TODO:
- Finish all examples
- Add a helper class for converting property ID to string. ie: Position ID > Position name
- Play-by-play