Minishlink / web-push-php-example

An example for sending Web Push notifications, using web-push-php
MIT License
255 stars 89 forks source link

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

Closed maclevemarcus closed 4 years ago

maclevemarcus commented 5 years ago

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)
            );`
nomanaadma commented 5 years ago

did you find any solution?

g-regor commented 4 years ago

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