【问题标题】:WebPush failing to sendWebPush 发送失败
【发布时间】:2020-10-15 10:41:35
【问题描述】:

我正在使用 Minishlink/WebPush 包将推送通知从我的服务器发送到我的客户端,但我收到此错误:

array(3) {
  ["success"]=>
  bool(false)
  ["endpoint"]=>
  string(188) "***"
  ["message"]=>
  string(179) "cURL error 77: error setting certificate verify locations:
  CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt
  CApath: none (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)"
}

这是我的代码:

require __DIR__ . '../../../vendor/autoload.php';
use Minishlink\WebPush\WebPush;

$vapidAuth = array(
                'VAPID' => array(
                    'subject' => 'https://github.com/Minishlink/web-push-php-example/',
                    'publicKey' => '***',
                    'privateKey' => '***'
                )
            );
$webPush = new WebPush($vapidAuth);
$res = $webPush->sendNotification(
     $subscription['ius_endpoint'],
     'hello world!',
     $subscription['ius_p256dh'],
     $subscription['ius_auth'],
     true
);

我的客户端上的 sw 代码正在工作,因为我尝试使用 javascript 手动将通知推送到我注册的 sw。

【问题讨论】:

    标签: javascript php progressive-web-apps web-push


    【解决方案1】:

    我找到了答案here

    1. 从以下位置下载证书:https://curl.haxx.se/ca/cacert.pem
    2. 将 cacert.pem 文件重命名为 curl-ca-bundle.crt
    3. 将文件复制到路径/to/xampp/apache/bin
    4. 重启apache

    【讨论】:

    猜你喜欢
    • 2017-01-13
    • 1970-01-01
    • 2020-07-28
    • 2011-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-29
    • 2016-04-11
    相关资源
    最近更新 更多