我们可以用php从pusher获取数据吗

时间:2020-08-26 12:10:14

标签: pusher

我正在学习pusher,我可以看到获取需要使用jquery的实时数据,并将数据推送到后端需要使用php语言,我们可以使用php而不是jquery来获取该数据吗?可能吗 ?我还能看到pusher仅实时工作,如果刷新页面并需要获取所有存储的pusher数据,会发生什么情况?

backend.php

$options = array(
   'cluster' => 'ap2',
   'encrypted' => true
 );

 $pusher = new Pusher\Pusher(
   '***',
   '***',
   '***',
   $options
 );

if($pusher->trigger('test_channel', 'my_event', $data)) {
echo 'success';
} else {
echo 'error';
}

index.html

var channel = pusher.subscribe('test_channel');

// bind the server event to get the response data and append it to the message div
channel.bind('my_event',
    function(data) {
        console.log("event data");
        console.log(data);
    });

我们可以用php获取那些数据吗?

0 个答案:

没有答案