Laravel和Pusher - 未发送API消息

时间:2017-03-02 13:12:41

标签: php laravel pusher

我试图让Pusher使用我的Laravel应用程序。我有一个私人频道,用户通过身份验证并连接到它。当我从Pusher Debug Console发送测试消息时,我收到了客户端的条目。

我遇到了从L5应用向推送器发送活动的问题。事件被触发,在我的L5日志中,我看到以下内容:

[2017-03-02 13:07:23] local.INFO: Broadcasting [App\Events\xyz] on channels [private-xyz_35] with payload:
{
    "message": {
        "user": "35",
        "code": "KKKK1111"
    },
    "socket": null
}  

我的.ENV文件和广播配置都已正确配置。当我触发事件时,我的Pusher调试控制台中没有看到API消息。

有谁能指出我在这里做错了什么?

这是我的活动:

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

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

    /**
     * Create a new event instance.
     *
     * @return void
     */

    /**
     * Only (!) Public members will be serialized to JSON and sent to Pusher
    **/
    public $message;


    public function __construct($message)
    {
        $this->message = $message;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('xyz_' . $this->message['user']);
    }
}

1 个答案:

答案 0 :(得分:0)

我刚刚意识到我忘了验证我的Pusher帐户上的电子邮件。经过验证,现在一切正常(第一次使用Pusher)。