プッシャーPHP/JS APIを使用してプライベート メッセージング チャットを実装したいと考えています。プライベート チャネルと php で認証エンドポイントをセットアップするための助けが必要です。プライベート チャネルのユーザー認証を管理するデフォルトの方法があるかどうかは、ドキュメントから明らかではありません。少しグーグルで検索していくつかの例を見つけましたが、laravelを使用していないので適用できません。任意の提案をいただければ幸いです。
JS
Pusher.logToConsole = true;
var pusher = new Pusher('12xxxxxx', {
cluster: 'us',
forceTLS: true
});
var channel = pusher.subscribe('private-encrypted-test-channel');
channel.bind('message-event', function(data) {
alert(JSON.stringify(data));
});
channel.bind('pusher:subscription_succeeded', function(members) {
console.log(members);
console.log('successfully subscribed!');
});
PHP
require_once __DIR__.'/vendor/autoload.php';
$options = array(
'cluster' => 'eu',
'useTLS' => true
);
$pusher = new Pusher\Pusher(
'12xxxxx',
'2xxxxxx',
'8xxxxxx',
$options
);
$data['message'] = 'hello world';
$pusher->trigger('private-encrypted-test-channel', 'message-event', $data);
php でユーザーを認証し、後で js でプッシャー API を使用する正しい方法は何ですか?