Enviar para todos
POSThttps://pushvex.online/api/v1/send-all.php
Envia uma notificação para todos os inscritos do site.
Corpo da requisição
| Parâmetro | Tipo | Obrigatório | Descrição |
|---|---|---|---|
title | string | Sim | Título (até 100 caracteres). |
message | string | Sim | Texto (até 300 caracteres). |
target_url | string | Não | URL aberta ao clicar (http/https). |
icon | string | Não | URL do ícone. Usa o ícone padrão do site se omitido. |
image | string | Não | URL de imagem grande. |
ttl | int | Não | Segundos que o navegador guarda a mensagem se o aparelho estiver offline (padrão 86400). |
Exemplo
curl -X POST https://pushvex.online/api/v1/send-all.php \
-H "X-Site-Key: SUA_SITE_KEY" \
-H "X-Auth-Token: SEU_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Promoção relâmpago",
"message": "30% de desconto até meia-noite!",
"target_url": "https://seusite.com/promo"
}'Resposta
{
"status": "success",
"notification_id": 42,
"total": 1520,
"sent": 1498,
"failed": 22
}O envio é feito durante a requisição; com muitos inscritos ela pode demorar alguns segundos. Inscrições expiradas (falhas 404/410) são removidas automaticamente.
PHP
$ch = curl_init('https://pushvex.online/api/v1/send-all.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-Site-Key: SUA_SITE_KEY',
'X-Auth-Token: SEU_AUTH_TOKEN',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'title' => 'Novo post',
'message' => 'Acabamos de publicar algo para você.',
'target_url' => 'https://seusite.com/novo-post',
]),
]);
$resp = json_decode(curl_exec($ch), true);