【发布时间】:2016-08-26 02:17:15
【问题描述】:
我正在尝试建立一个存在渠道。但是返回的auth字符串不正确。
这是后端代码:
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的推桥
我想试试官方的 pusher-php-server,但是 composer install 后,我不知道如何在我的代码中使用它。我想知道https://github.com/pusher/pusher-http-php是否有同样的问题。
【问题讨论】: