PHP code example of codecabin / tethered-uptime-php

1. Go to this page and download the library: Download codecabin/tethered-uptime-php 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/ */

    

codecabin / tethered-uptime-php example snippets


{
  "  "codecabin/tethered-uptime-php": "*"
  }
}

php composer.phar install



php composer.phar 



$uptime = new TetheredUptime(
    (object) array(
        'apikey' => '[APIKEY]', 
        'monitorId' => 1,
        'modifiers' => (object) array(
            'metrics.list' => array(
                function($list) {
                    $list[] = (object) array(
                        'key' => 'custom.metric',
                        'value' => 5,
                        'label' => 'Custom Metric',
                        'type' => 'percentage',
                        'widget' => 'pie'
                    );

                    return $list;
                }
            )
        )
    )
);

$uptime->sync();

$uptime = new TetheredUptime($configuration);

$uptime->addModifier('status.code', function($code){
    return $code * 2;
});

$uptime->sync();

$uptime = new TetheredUptime((object) array(
    'apikey' => '[APIKEY]', 
    'monitorId' => 1,
    'events' => (object) array(
        'sync' => array(
            function() {
                echo "Sync has been called";
            }
        )
    )
));

$uptime->sync();

$uptime = new TetheredUptime($configuration);

$uptime->listen('status.complete', function($response){
    echo "Response was received: <br>";
    var_dump($response);
});

$uptime->sync();

$uptime = new TetheredUptime($configuration);

// Create an incident
$response = $uptime->pushIncident("Server issue", "PHP server is experiencing issues, with these details...", "PHP Server", 0);

$uptime = new TetheredUptime($configuration);

// Add a listener
$uptime->listen('ready', function() {
    echo "scheduler is running";
});

$uptime = new TetheredUptime($configuration);

$data = (object) array(
    "apikey" => $uptime->configuration->apikey
);

// Get notifiers linked to your account
$response = $uptime->get('/notifiers');

$uptime = new TetheredUptime($configuration);

$data = (object) array(
    "apikey" => $uptime->configuration->apikey,
    /* Additional fields 

$uptime = new TetheredUptime($configuration);

$data = (object) array(
    "apikey" => $uptime->configuration->apikey,
    "id" => 1
);

// Delete notifier linked to your account
$response = $uptime->delete('/notifier');