我正在尝试订阅api的频道。我尝试使用'ratchetphp / Pawl'和Laravel,这是我的代码:
$loop = Factory::create();
$connector = new Connector($loop);
$connector('wss://api.poloniex.com')
->then(function(WebSocket $conn) {
$conn->send('{"event": "subscribe","channel":"ticker","pair": "BTC_ETH"}');
$conn->on('message', function(MessageInterface $msg) use ($conn) {
var_dump($msg);
});
}, function(\Exception $e) use ($loop) {
/** hard error */
echo "Could not connect: {$e->getMessage()}\n";
$loop->stop();
});
$loop->run();
但是,我收到错误:
此服务器只能说WebSocket子协议wamp.2.cbor.batched,wamp.2.cbor,wamp.2.msgpack.batched,wamp.2.msgpack,wamp.2.json.batched,wamp.2.json
我还尝试了$connector('wss://api.poloniex.com', ['wamp'])
和$connector('wss://api.poloniex.com', ['wamp2'])
,但同样的错误仍然存在。
我做错了什么?