我们可以用php从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获取那些数据吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)