$ auth使用PHP WebPush库返回错误

问题描述 投票:0回答:1

数据库提取订阅推送通知的用户然后循环遍历所有这些用户并使用我的应用程序密钥向端点发送通知 - 这是正确的

但该文件返回错误,说明$ auth键丢失

    $auth = array(
        'subject' => 'omitted',
        'publicKey' => 'omitted',
        'privateKey' => 'omitted'
    );

    $webPush = new WebPush($auth);

    while($row = $subscriptions->fetch_assoc()){

        $res = $webPush->sendNotification(
            $subscription = Subscription::create([
                'endpoint' => $row['endpoint'],
                'publicKey' => $row['p256dh'],
                'authToken'=> $row['auth'],
                'contentEncoding' => 'aesgcm'
            ]),
            $notification,
            true
        );


    }
php web-push
1个回答
0
投票

您的$ auth数组应如下所示:

    $auth = array(
        'VAPID' => array(
            'subject' => '',
            'publicKey' => '',
            'privateKey' => ''
        ),
    );
© www.soinside.com 2019 - 2024. All rights reserved.