Minishlink / web-push-php-example

An example for sending Web Push notifications, using web-push-php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

syntax error, unexpected '?', expecting variable (T_VARIABLE)

maclevemarcus opened this issue · comments

im getting this error and im not sure why.

we

Below is the code that i used :

`$sub_endpoint = $endpoint;
$sub_publicKey = 'BDASezNQ-********************';
$sub_authToken = $authToken;
$sub_contentEncoding ='aesgcm';
$notifications = [
[
'subscription' => Subscription::create([
'endpoint' => $sub_endpoint,
'publicKey' => $sub_publicKey,
'authToken' => $sub_authToken,
'contentEncoding' => $sub_contentEncoding,
]),
'payload' => '{msg:"test"}',
],
];

            $auth = array(
                'VAPID' => array(
                    'subject' => 'web.example.com', 
                    'publicKey' => 'BDASezNQ-*********', 
                    'privateKey' => 'CqPxWr_*******' 
                    //'pemFile' => './keys/private_key.pem' // if you have a PEM file and can link to it on your filesystem        
                ),
            );
            $defaultOptions = array(
                'TTL' => 300, // defaults to 4 weeks
                'urgency' => 'normal', // protocol defaults to "normal"
                'topic' => 'push', // not defined by default - collapse_key
            );

            $webPush = new WebPush($auth, $defaultOptions);

            // send multiple notifications with payload

            $webPush->flush();

            // send one notification and flush directly
            $webPush->sendNotification(
                $notifications[0]['subscription'],
                $notifications[0]['payload'], // optional (defaults null)
                true // optional (defaults false)
            );`

did you find any solution?

That's an issue with the web-push-php library, not this example. Are you running PHP 7.1+ as mentioned in the requirements?