PHP

LogHive provides a simple REST API that you can use to push events and errors. Here is an example code for PHP:

Push Event

<?php
// curl
$url = 'https://api.loghive.app/v1/event/add';

$data = array(
    'project' => 'yourprojectname',
    'group' => 'yourgroupname',
    'event' => 'your-event-name',
    'description' => 'your-description',
    'notify' => false
);
$json_data = json_encode($data);

// Init
$ch = curl_init();

// cURL-Optionen
curl_setopt($ch, CURLOPT_URL, $url); // Setzen der URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Setzen von CURLOPT_RETURNTRANSFER auf true, um die Antwort in eine Variable zu speichern
curl_setopt($ch, CURLOPT_POST, true); // Setzen von CURLOPT_POST auf true, um eine POST-Anfrage zu senden
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); // Setzen des JSON-Body
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json', // Setzen des Content-Type-Headers auf application/json
    'ApiKey: YourPersonalApiKey' // Setzen des Authorization-Headers
));

// Exec
$response = curl_exec($ch);

if(curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
}
curl_close($ch);

if($response) {
    echo($response);
}
?>

Push Insight

$url = 'https://api.loghive.app/v1/insight/add';

$data = array(
    'projectName' => 'yourprojectname',
    'name' => 'insightname',
    'value' => 100
);
$json_data = json_encode($data);

...

Set Online / Offline

$url = 'https://api.loghive.app/v1/insight/add';

// set online
$data = array(
    'projectName' => 'yourprojectname',
    'name' => 'system1',
    'value' => 1
);
$json_data = json_encode($data);

// set offline
$data = array(
    'projectName' => 'yourprojectname',
    'name' => 'system1',
    'value' => 0
);
$json_data = json_encode($data);

...

Last updated