【发布时间】:2016-10-24 08:45:00
【问题描述】:
我在 laravel 5.2 上工作,我添加了 vinkla/laravel-pusher 在我的网站上做实时聊天应用程序,但我遇到了这个问题: “从 webapp 返回的 JSON 无效,但状态码为 200。” 这是我的控制器:
public function authMessageChat(Request $req)
{
$channelName = e($req->input('channel_name'));
$socketId = e($req->input('socket_id'));
$auth = $this->pusher->presence_auth($channelName, $socketId, auth()->user()->id);
return response($auth);
}
这是我的脚本:
var pusher = new Pusher('{{env("PUSHER_KEY")}}', {
authEndpoint: '../auth',
auth: {
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
params: {
id: currentUser.id
}
}
});
var channel = pusher.subscribe('{{$chatChannel}}');
channel.bind('pusher:subscription_error', function(PusherError){
console.log('PusherError' + PusherError);
});
channel.bind('new-message', function(data) {
console.log(data.sender);
)};
推杆错误:
【问题讨论】:
标签: php json laravel-5.2 pusher