Download the PHP package drsdre/yii2-footballapi without Composer
On this page you can find all versions of the php package drsdre/yii2-footballapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drsdre/yii2-footballapi
More information about drsdre/yii2-footballapi
Files in drsdre/yii2-footballapi
Package yii2-footballapi
Short Description Yii2 Extension for football-api.com API access
License BSD-3-Clause
Homepage https://github.com/drsdre/yii2-footballapi
Informations about the package yii2-footballapi
Yii2-xmlsoccer
Yii2 client for Football API API
Full API Documentation here: http://football-api.com/documentation/
Requirements:
PHP5 with CURL. SimpleXML extensions only needed if XML is chosen as output.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require
section of your composer.json
file.
Usage
You can either setup the client as an application component:
or use the client directly in your code:
Configuration
The output format of the the API calls can be changed by adding a output type parameter:
Default value: JSON. Options include: XML, JSON, PHPARRAY, PHPOBJECT, LINE, CONSOLE, VAR.
Optionally a cache component can be added for example to keep the client returning data during a time-out:
To facilitate a check to detect data changes, a content hash can be generated by setting the parameter 'generate_hash' to true (currently only supported in XML, PHPARRAY & PHPOBJECT output type). The output will then include two new attributes:
- contentHash: MD5 hash
- sourceURL: URL used to retrieve the data
If you need to have the API be executed via a specific network adapter it's possible the specify the outgoing IP:
How to use API:
Go to Sign up for Free and retrieve the API key for access to the football-api.com API.
Methods Available
Go to http://football-api.com/documentation/ for more info about methods and parameters including online testing.
Examples:
List competitions
try {
$client = new \FootballAPI\Client([
'api_key' => 'xxx',
]);
$competitions=json_decode($soccer->competitions());
echo "Competitions List:<br>";
foreach($competitions as $competition){
echo "<b>".$competition->name."</b> ".$competition->region."<br>";
}
}
catch(Exception $e) {
echo "FootballAPI Exception: ".$e->getMessage();
}
If your server has multiple IP's available, you can set any IP for request:
try {
$client = new \FootballAPI\Client([
'api_key' => 'xxx',
]);
$soccer->setRequestIp("ip_for_request");
$result=json_decode($soccer->standings(["comp_id"=>1064]));
var_dump($result);
}
catch(Exception $e) {
echo "FootballAPI: ".$e->getMessage();
}