PHP
Send events from any PHP application, including Laravel, WordPress themes, and plain PHP.
Using cURL
<?php
function sendFlowAlert(string $event, string $title, string $body = '', string $priority = 'NORMAL'): void {
$payload = json_encode([
'event' => $event,
'title' => $title,
'body' => $body,
'priority' => $priority,
]);
$ch = curl_init('https://api.flowalert.io/v1/events');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Api-Key: ' . $_ENV['FLOWALERT_API_KEY'],
],
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 201) {
error_log('FlowAlert error: ' . $response);
}
}
// Usage
sendFlowAlert('booking.created', 'New Booking — John Smith', 'Sunset Cruise · 4 guests');
sendFlowAlert('payment.failed', 'Payment failed', 'Order #5512 — card declined', 'HIGH');Laravel example
<?php
use Illuminate\Support\Facades\Http;
// In a service or controller
Http::withHeaders([
'X-Api-Key' => config('services.flowalert.key'),
])->post('https://api.flowalert.io/v1/events', [
'event' => 'order.created',
'title' => "New Order #{$order->id}",
'body' => "Total: {$order->total} · {$order->customer_name}",
'priority' => 'NORMAL',
]);Add to your config/services.php:
'flowalert' => [
'key' => env('FLOWALERT_API_KEY'),
],💡
Store your API key in your .env file as FLOWALERT_API_KEY. Never commit it to version control.