-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_ws.php
40 lines (26 loc) · 1.04 KB
/
example_ws.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use bitget\internal\BitgetWsHandle;
use bitget\internal\Listener;
use bitget\listener\DefListener;
use bitget\model\ws\SubscribeReq;
require './vendor/autoload.php';
$bitgetWsClient = BitgetWsHandle::builder()->isLogin(true)->listener(new class extends Listener{
public function recevie(string $msg): void
{
print_r("def:\n".$msg."\n");
}
})->build();
$sub = array(new SubscribeReq("mc","trade","BTCUSDT"));
$bitgetWsClient->subscribeDef($sub);
$sub2 = array(new SubscribeReq("mc","trade","ETHUSDT"));
$bitgetWsClient->subscribe($sub2,new class extends Listener {
public function recevie(string $msg): void
{
print_r("appoint:\n".$msg."\n");
}
});
// Bitget Websocket server domain is "wss://ws.bitget.com/spot/v1/stream"
// which in PHP it automatically connect to "wss://ws.bitget.com:443/spot/v1/stream"
// and so got connection rejected because the port 443 is not enabled in Bitget's websocket server
// Please try an alternative or, switch to another Dev language
// $bitgetWsClient->startWorker();