0
我正在嘗試使用Laravel 5.3和Pusher爲我的Web應用程序構建實時通知。我能夠將消息推送到Pusher調試控制檯。 我的服務器端腳本:Laravel Pusher錯誤「無回調」錯誤
$options = array(
'cluster' => 'ap2',
'encrypted' => true
);
$pusher = new Pusher(
'xxxxxxxxxx', // removed for safety
'xxxxxxxxxx', // removed for safety
'xxxxx', // removed for safety
$options
);
$data['message'] = ($user->name)." like your status";
$pusher->trigger('my-channel', 'PusherEvent', $data);
而我的客戶端腳本:
<script src="https://js.pusher.com/4.0/pusher.min.js"></script>
// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;
var pusher = new Pusher('xxxxxxxxx', {
cluster: 'ap2',
encrypted: true
});
var channel = pusher.subscribe('my-channel');
channel.bind('PusherEvent', function(data) {
alert(data.message);
});
我想在我的webpage.Javascript警報已啓用我瀏覽器控制檯顯示如下:
Pusher : Event sent : {"event":"pusher:subscribe","data":{"channel":"my-channel"}} pusher.min.js:8:2594
Pusher : Event recd : {"event":"pusher_internal:subscription_succeeded","data":{},"channel":"my-channel"}
Pusher : No callbacks on my-channel for pusher:subscription_succeeded
這可能是什麼原因?