Pixela client for PHP
- PHP 5.5 or later
composer require tsmsogn/pixela
<?php
$client = new \Pixela\Client('tsmsogn-ghost', 'thisissecret');
<?php
$user = $client->api('User');
// Create user
$user->create();
// Update user
$user->update('thisisnewsecret');
// Delete user
$user->delete();
<?php
$graph = $client->api('Graphs');
// Create graph
$graph->setId('test-graph')
->setName('graph-name')
->setUnit('commit')
->setType('int')
->setColor('shibafu');
$graph->create();
// Get graphs
$graph->get();
// Get SVG
$graph->getSVG()
// Update graph
$graph->setName('new-test-graph')
->setUnit('calory')
->setColor('momiji')
->setTimezone('UTC')
->setPurgeCacheURLs(array(
'https://camo.githubusercontent.com/xxx/xxxx'
));
$graph->update();
// Delete graph
$graph->delete();
// Get URL
$graph->getURL();
<?php
$pixel = $client->api('Pixel');
// Create pixel
$pixel->setGraphID('test-graph')
->setDatetime(new \DateTime())
->setQuantity(1);
$pixel->post();
// Get pixel
$pixel->get();
// Update pixel
$pixel->setQuantity(10)
->setOptionalData(json_encode('foo'));
$pixel->update();
// Increment pixel
$pixel->increment();
// Decrement pixel
$pixel->decrement();
// Delete pixel
$pixel->delete();
<?php
$webhook = $client->api('Webhooks');
// Create webhook
$webhook->setGraphID('test-graph')
->setType('increment');
$webhook->create();
// Get webhooks
$webhook->get();
// Invoke webhook
$webhook->invoke();
// Delete webhook
$webhook->delete();