1. Go to this page and download the library: Download kwk/geckoboard-dataset-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kwk / geckoboard-dataset-api example snippets
namespace Preview;
use Kwk\Geckoboard\Dataset\DatasetBuilder;
use Kwk\Geckoboard\Dataset\DataSetInterface;
use Kwk\Geckoboard\Dataset\Type\DateType;
use Kwk\Geckoboard\Dataset\Type\NumberType;
class TestDataset implements DataSetInterface
{
/**
* {@inheritDoc}
*/
public function getName()
{
return 'test';
}
/**
* {@inheritDoc}
*/
public function getDefinition()
{
return (new DatasetBuilder())
->addField('date_field_id', new DateType('Date'))
->addField('number_field_id', new NumberType('Number'))
->build();
}
}
namespace Preview;
use Kwk\Geckoboard\Dataset\DataSetRowInterface;
class TestDatarow implements DataSetRowInterface
{
/**
* {@inheritDoc}
*/
public function getData()
{
return [
'date_field_id' => '2016-12-31',
'number_field_id' => 1021,
];
}
}
$httpClient = new \Guzzle\Http\Client('https://api.geckoboard.com');
$client = new \Kwk\Geckoboard\Dataset\Client($httpClient, 'YOUR_API_KEY');
$client->create(new \Preview\TestDataset());
namespace Preview\Dataset;
use Kwk\Geckoboard\Dataset\DataSetRowInterface;
class TestDatarow implements DataSetRowInterface
{
/**
* {@inheritDoc}
*/
public function getData()
{
return [
'param1' => 'val1',
'param2' => 'val2',
];
}
}