Answer the question
In order to leave comments, you need to log in
How to connect from php(client) to Socket.io server?
Hello. We are trying to connect to the Online PBX service via the Websocket API, all the script logic is written in php, so we decided to make a simple client in php too, this is the only module that should be done in js, but alas, no.
Problem. OnlinePBX has a library for interacting with the API , but the API itself doesn't suit us either .
Right now I'm trying to connect to them using Ratchetphp Pawl like this:
$loop = React\EventLoop\Factory::create();
$connector = new Ratchet\Client\Connector($loop);
$connector('ws://crmgt4u.onpbx.ru:8094')->then(function(Ratchet\Client\WebSocket $conn) {
$conn->send('{"domain":"МОЙ ДОМЕН","key":"МОЙ КЛЮЧ","port":8094}');
$conn->on('message', function(\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($conn) {
echo "Получены данные: {$msg}\n";
$conn->close();
});
}, function(\Exception $e) use ($loop) {
echo "Нет соединения: {$e->getMessage()}\n";
$loop->stop();
});
$loop->run();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question