-
Notifications
You must be signed in to change notification settings - Fork 310
Closed
Description
PHP Fatal error: Uncaught TypeError: Jose\Component\Core\Util\Ecc\PrivateKey::create(): Argument #1 ($secret) must be of type Brick\Math\BigInteger, GMP given, called in /home/dppop/Desktop/push/vendor/minishlink/web-push/src/Encryption.php on line 392 and defined in /home/dppop/Desktop/push/vendor/web-token/jwt-util-ecc/PrivateKey.php:57
Stack trace:
#0 /home/dppop/Desktop/push/vendor/minishlink/web-push/src/Encryption.php(392): Jose\Component\Core\Util\Ecc\PrivateKey::create()
#1 /home/dppop/Desktop/push/vendor/minishlink/web-push/src/Encryption.php(118): Minishlink\WebPush\Encryption::calculateAgreementKey()
#2 /home/dppop/Desktop/push/vendor/minishlink/web-push/src/Encryption.php(66): Minishlink\WebPush\Encryption::deterministicEncrypt()
#3 /home/dppop/Desktop/push/vendor/minishlink/web-push/src/WebPush.php(230): Minishlink\WebPush\Encryption::encrypt()
#4 /home/dppop/Desktop/push/vendor/minishlink/web-push/src/WebPush.php(173): Minishlink\WebPush\WebPush->prepare()
#5 /home/dppop/Desktop/push/index.php(57): Minishlink\WebPush\WebPush->flush()
#6 {main}
thrown in /home/dppop/Desktop/push/vendor/web-token/jwt-util-ecc/PrivateKey.php on line 57
my code
<?php
use Minishlink\WebPush\WebPush;
use Minishlink\WebPush\Subscription;
require_once "vendor/autoload.php";
// array of notifications
$notifications = [
[
'subscription' => Subscription::create([
'endpoint' => 'https://updates.push.services.mozilla.com/push/abc...', // Firefox 43+,
'publicKey' => 'BPcMbnWQL5GOYX/5LKZXT6sLmHiMsJSiEvIFvfcDvX7IZ9qqtq68onpTPEYmyxSQNiH7UD/98AUcQ12kBoxz/0s=', // base 64 encoded, should be 88 chars
'authToken' => 'CxVX6QsVToEGEcjfYPqXQw==', // base 64 encoded, should be 24 chars
]),
'payload' => 'hello !',
], [
'subscription' => Subscription::create([
'endpoint' => 'https://fcm.googleapis.com/fcm/send/abcdef...', // Chrome
]),
'payload' => null,
], [
'subscription' => Subscription::create([
'endpoint' => 'http//localhost:63342/push',
'publicKey' => 'BIjz9EfK9t_hVSOF4xTd2XVe8Cax3H_t7v4FpYJHIkdERyRSd6LqVUqFlSA5fNGHrDpMkEIVzV9V5Vt6WGmgL7g',
'authToken' => 'NzXG5XJAgE8n3w4Jp7gCCk7Nfc2i1z_UYOLxDfvIizc',
'contentEncoding' => 'aesgcm', // one of PushManager.supportedContentEncodings
]),
'payload' => '{msg:"test"}',
], [
'subscription' => Subscription::create([ // this is the structure for the working draft from october 2018 (https://www.w3.org/TR/2018/WD-push-api-20181026/)
"endpoint" => "http//localhost:63342/push",
"keys" => [
'p256dh' => 'BIjz9EfK9t_hVSOF4xTd2XVe8Cax3H_t7v4FpYJHIkdERyRSd6LqVUqFlSA5fNGHrDpMkEIVzV9V5Vt6WGmgL7g',
'auth' => 'NzXG5XJAgE8n3w4Jp7gCCk7Nfc2i1z_UYOLxDfvIizc'
],
]),
'payload' => '{"msg":"Hello World!"}',
],
];
$webPush = new WebPush();
// send multiple notifications with payload
foreach ($notifications as $notification) {
$webPush->queueNotification(
$notification['subscription'],
$notification['payload'] // optional (defaults null)
);
}
/**
* Check sent results
* @var MessageSentReport $report
*/
foreach ($webPush->flush() as $report) {
$endpoint = $report->getRequest()->getUri()->__toString();
if ($report->isSuccess()) {
echo "[v] Message sent successfully for subscription {$endpoint}.";
} else {
echo "[x] Message failed to sent for subscription {$endpoint}: {$report->getReason()}";
}
}
/**
* send one notification and flush directly
* @var MessageSentReport $report
*/
$report = $webPush->sendOneNotification(
$notifications[0]['subscription'],
$notifications[0]['payload'] // opti
);
Metadata
Metadata
Assignees
Labels
No labels