2016-05-01 204 views
6

我试图建立一个存在频道。但是,返回的授权字符串不正确。Laravel Pusher Presence频道验证错误

这里是后端代码:

class pusherController extends Controller 
{ 

    protected $pusher; 

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

    public function pusherPinyinAuth(Request $request) 
    { 
     if($request->user()) { 
      $user = $request->user(); 
      $auth= $this->pusher->presence_auth($request->input('channel_name'),$request->input('socket_id'), $user->id, array('h'=>'user_info')); 
      return response($auth); 
     } 
    } 
} 

错误消息

Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Auth value for subscription to presence-5 is invalid: should be of format 'key:signature'"}}} 

我想误差由附加引起的“:”在auth字符串之前添加。但我手动删除它仍报告相同的错误。这里是我的字符串输出:

{auth: ":8dacf362f8fe62bae42c33dfe5511d3d1c42144685d5843a6a6a8014490ed0f6",…} 

我利用推进大桥https://github.com/vinkla/pusher

我想尝试的官方推的PHP服务器,但作曲家安装后,我不知道如何在我的代码中使用它。我想知道https://github.com/pusher/pusher-http-php是否有同样的问题。

回答

5

对我而言,这是由推送键造成的,秘密和app_id值在生产中没有正确设置。

+0

你是什么意思?是看如果也许我在做同样的错误... – Juli15

+0

您必须确保您的.env文件在服务器上包含所有必要的变量,并且它们设置正确。 – Moritur