<?php
require_once dirname(__DIR__,2).'/config.php';
require_once __DIR__.'/push.lib.php';
require_once dirname(__DIR__,2).'/vendor/autoload.php';
use Minishlink\WebPush\WebPush;
use Minishlink\WebPush\Subscription;
$data=json_decode(file_get_contents('php://input'),true);
if(!$data){echo"fail";exit;}
$subscription=Subscription::create($data);
$webPush=new WebPush([
'VAPID'=>[
'subject'=>PUSH_SUBJECT,
'publicKey'=>PUSH_PUBLIC_KEY,
'privateKey'=>PUSH_PRIVATE_KEY,
],
]);
$result=$webPush->sendOneNotification(
$subscription,
json_encode([
'title'=>__('Notification Test'),
'body'=>__('The notification is working properly 🎉'),
'url'=>"/index.php"
])
);
echo"ok";
