-1
我想創建一個網頁推送通知在PHP中,但我沒有確切的程序。以下是我找到的代碼,但它不起作用。PHP:創建網頁推送通知
<?php
require __DIR__ . '/../vendor/autoload.php';
use Minishlink\WebPush\WebPush;
$subscription = json_decode(file_get_contents('php://input'), true);
$auth = array(
'VAPID' => array(
'subject' => '`enter code here`',
'publicKey' => '**********',
'privateKey' => '***********',
),
);
$webPush = new WebPush($auth);
$res = $webPush->sendNotification(
$subscription['endpoint'],
"Hello!",
$subscription['key'],
$subscription['token'],
true
);
請建議正確的步驟。
什麼不起作用?你有什麼錯誤嗎? – Jerodev
可能是https://gist.github.com/prime31/5675017它對你有幫助 –
是的,它有一些內部服務器錯誤ñ它沒有通知。 – Nisha