我遇到一种情况,我想显示从此API wss://stream.binance.com:9443/ws/btcusdt@depth
接收到的动态数据。我想使用ratchet
,并且编写了这样的代码
require __DIR__ . '\vendor\autoload.php';
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
\Ratchet\Client\connect('wss://stream.binance.com:9443/ws/btcusdt@depth')->then(function($conn) {
$conn->on('message', function($msg) use ($conn) {
echo "Received: {$msg}\n";
// $conn->close();
});
// $conn->send('Hello World!');
}, function ($e) {
echo "Could not connect: {$e->getMessage()}\n";
});
但是在这里给了我以下错误:
Fatal error: Uncaught Error: Call to undefined function Ratchet\Client\connect()
我不确定在哪里查找错误。