Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 419尝试使用Laravel Echo、Vue和Pusher设置事件时发生身份验证错误_Php_Laravel_Vue.js_Vuejs2_Laravel Echo - Fatal编程技术网

Php 419尝试使用Laravel Echo、Vue和Pusher设置事件时发生身份验证错误

Php 419尝试使用Laravel Echo、Vue和Pusher设置事件时发生身份验证错误,php,laravel,vue.js,vuejs2,laravel-echo,Php,Laravel,Vue.js,Vuejs2,Laravel Echo,我目前正在学习如何正确使用Laravel echo作为推动者,但在过去的几天里,我遇到了困难,我无法解决这个问题 我一直收到419错误 /broadcasting/auth 419 (proxy reauthentication required) 但我看不出问题出在哪里 我在控制器中有一个方法,在插入消息后触发事件 /** The headers of the controller class **/ use App\Message; use App\User; use Auth; use

我目前正在学习如何正确使用Laravel echo作为推动者,但在过去的几天里,我遇到了困难,我无法解决这个问题

我一直收到419错误

/broadcasting/auth 419 (proxy reauthentication required)
但我看不出问题出在哪里

我在控制器中有一个方法,在插入消息后触发事件

/** The headers of the controller class **/

use App\Message;
use App\User;
use Auth;
use App\Events\MessagePosted;


/*The event that is fired*/

event ( new MessagePosted($msg, Auth::user()) );
其中$msg是一个消息实例

这是发布的事件类消息

class MessagePosted implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    /**
     * Message
     *
     * @var Message
     */
     public $message;

    /**
     * User
     *
     * @var User
     */
     public $user;

    public function __construct(Message $message, User $user)
    {
        $this->message = $message;
        $this->user = $user;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PresenceChannel('chatroom.'.$this->message);
    }
}
这就是我在channels.php中的内容

Broadcast::channel('App.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

Broadcast::channel('chatroom.{$message}', function ($user, $message){
    return $user->id == $message->id_sender || $user->id == $message->id_receiver;
});
除此之外,我不知道是什么原因导致了这个错误,我得到了关于laravel文档和一些问题的所有信息

在broadcasting.php上,我得到:

'connections' => [

        'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_KEY'),
            'secret' => env('PUSHER_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'encrypted' => true,
            ],
        ],
...
];
在bootstrap.js上,我取消了文档中所述行的注释:

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key : "I PLACED MY APP KEY DIRECTY HERE"
    cluster : "us2"
});
关于我的广播服务提供商

public function boot()
{
    Broadcast::routes();

    require base_path('routes/channels.php');
}
你试过了吗

<meta name="csrf-token" content="{{ csrf_token() }}">