2016-05-01 67 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