You can log events from anywhere in your stack by simply making a HTTP request to the following endpoint
PUT https://api.blueradar.net/log
This endpoint requires the following:
site_id
(required)
string
api_token
(required)
string
channel
(required)
string
title
(required)
string
description
(optional)
string | null
icon
(optional)
string | null
When successful the api will return a http status of 200
Any other status will include either an error message as text. For example:
failed to find channel
use Carbon\Carbon;
use Illuminate\Support\Facades\Http;
class BlueRadar
{
static function log(
string $title,
string $description,
string $icon,
string $channel
) {
$siteId = env("BLUERADAR_SITE_ID");
$apiToken = env("BLUERADAR_SITE_API_TOKEN");
if (!$siteId || !$apiToken) {
return null;
}
$res = Http::put("https://api.blueradar.net/log", [
"site_id" => $siteId,
"api_token" => $apiToken,
"title" => $title,
"description" => $description,
"icon" => $icon,
"channel" => $channel,
]);
if (!$res->successful()) {
throw new \Exception(
"Server responded with {$res->status()} for log '{$title}'"
);
}
return true;
}
}
use BlueRadar;
class PostController extends Controller
{
public function store()
{
// ...
BlueRadar::log(
title: "New Post",
description: "{$user} created a new post"
icon: "✍️",
channel: "Posts"
);
// ...
}
}
curl -X GET https://api.blueradar.net/event \
-d site_id="YOUR_SITE_ID" \
-d api_token="YOUR_API_TOKEN" \
-d title="EVENT_TITLE" \
-d description="EVENT_DESCRIPTION" \
-d icon="EVENT_ICON" \
-d channel="CHANNEL_NAME"
fetch("https://api.blueradar.net/log", {
method: "PUT",
body: new URLSearchParams({
site_id: "YOUR_SITE_ID",
api_token: "YOUR_API_TOKEN",
title: "EVENT_TITLE",
description: "EVENT_DESCRIPTION",
icon: "EVENT_ICON",
channel: "CHANNEL_NAME",
}),
});
import requests
data = {
'site_id': 'YOUR_SITE_ID',
'api_token': 'YOUR_API_TOKEN',
'title': 'EVENT_TITLE',
'description': 'EVENT_DESCRIPTION',
'icon': 'EVENT_ICON',
'channel': 'CHANNEL_NAME',
}
response = requests.put('https://api.blueradar.net/log', data=data)
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.blueradar.net/log");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type" => "application/x-www-form-urlencoded",
]);
curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
"site_id=YOUR_SITE_ID&api_token=YOUR_API_TOKEN&title=EVENT_TITLE&description=EVENT_DESCRIPTION&icon=EVENT_ICON&channel=CHANNEL_NAME"
);
$response = curl_exec($ch);
curl_close($ch);