'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
我没有触及配置文件,我只是将凭据添加到 env,如果使用凭据,则可以直接使用
public function sendTestMessage()
{
$options = [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true
];
$pusher = new Pusher(
env('PUSHER_APP_KEY'),
env('PUSHER_APP_SECRET'),
env('PUSHER_APP_ID'),
$options
);
$data['message'] = 'hello world';
$pusher->trigger('test-channel', 'my-event', $data);
return response()->json(['message' => 'Event has been sent!']);
}
我在创建订单后发送了一个事件,但事件本身没有到达推送器调试控制台
我正在使用 Laravel 11