Pusher无法在Codeigniter中触发事件

时间:2018-07-04 14:55:24

标签: php codeigniter pusher

javascribe订阅频道在下面给出。Channel正确订阅。

 var pusher = new Pusher('Appkey', { cluster: 'ap2'});
 var channel = pusher.subscribe('publisher-token-from-javascript');

触发事件的方法

$pusher = new Pusher('$key', '$secret', '$id', $options);

$response = $pusher->trigger('my-channel0000', 'my-event', array('message' => 'hello world'));

推送代码始终会返回null

array (size=2)
  'body' => boolean false
  'status' => int 0

1 个答案:

答案 0 :(得分:1)

连接到备用群集时,不会更新CodeIgniter的Pusher库。旧库始终连接到(默认:http://api.pusherapp.com)主机。要解决您的问题,您必须确保凭据正确。

要快速解决问题,请检查是否可以在服务器端配置中将$ config ['pusher_host']配置为: http://api-[yourcluster].pusher.com

示例

$config['pusher_api_key'] = 'XXXXXXXXXXXXX';
$config['pusher_secret'] = 'XXXXXXXXXXXXXX';
$config['pusher_app_id'] = 'XXXXXX'; 
$config['pusher_host'] = 'http://api-eu.pusher.com';