PHP code example of tsmsogn / pixela

1. Go to this page and download the library: Download tsmsogn/pixela 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/ */

    

tsmsogn / pixela example snippets



$client = new \Pixela\Client('tsmsogn-ghost', 'thisissecret');


$user = $client->api('User');

// Create user
$user->create();
        
// Update user
$user->update('thisisnewsecret');

// Delete user
$user->delete();


$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();


$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();


$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();