Skip to content

Commit 0e18038

Browse files
committed
remove incorrect argument of websocket
1 parent 6864900 commit 0e18038

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

php/gateio.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,44 @@
1212
Class Gateio{
1313
private $key = "your key";
1414
private $secret = "your secret";
15-
15+
1616
public $id;
1717
public $method;
1818
public $params;
19-
19+
2020
public $sign;
21-
21+
2222
function __construct($id,$method,$params){
2323
$this->id = $id;
2424
$this->method = $method;
2525
$this->params = $params;
2626
}
27-
27+
2828
function getSign($nonce){
2929
$sign = hash_hmac('sha512',$nonce,$this->secret,true);
3030
$ss = base64_encode($sign);
3131
return $ss;
3232
}
33-
33+
3434
function msectime() {
3535
list($msec, $sec) = explode(' ', microtime());
3636
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
3737
return $msectime;
3838
}
39-
39+
4040
public $flag=false;
41-
42-
function request($req_str="market.btcusdt.kline.1min") {
43-
$GLOBALS['req_str'] = $req_str;
44-
$GLOBALS['callback'] = $callback;
41+
42+
function request() {
4543
$worker = new Worker();
4644
$worker->onWorkerStart = function($worker) {
4745
// ssl需要访问443端口
4846
$con = new AsyncTcpConnection('ws://ws.gateio.io:443/v3/');
49-
47+
5048
// 设置以ssl加密方式访问,使之成为wss
5149
$con->transport = 'ssl';
52-
53-
54-
50+
51+
52+
5553
$con->onConnect = function($con) {
5654
if($this->method == 'server.sign' || $this->method == 'order.query' || $this->method == 'order.subscribe' || $this->method == 'order.update' ||
5755
$this->method == 'order.unsubscribe' || $this->method == 'balance.query' || $this->method == 'balance.subscribe' ||
@@ -65,7 +63,7 @@ function request($req_str="market.btcusdt.kline.1min") {
6563
$this->flag=true;
6664
$con->send($data);
6765
}else{
68-
66+
6967
$data = json_encode([
7068
"id" => $this->id,
7169
"method" => $this->method,
@@ -74,8 +72,8 @@ function request($req_str="market.btcusdt.kline.1min") {
7472
$con->send($data);
7573
}
7674
};
77-
78-
75+
76+
7977
$con->onMessage = function($con, $data) {
8078
echo $data;
8179
if($this->flag){
@@ -90,11 +88,11 @@ function request($req_str="market.btcusdt.kline.1min") {
9088
$this->flag=false;
9189
}
9290
};
93-
91+
9492
$con->connect();
9593
};
9694

9795
Worker::runAll();
9896
}
9997

100-
}
98+
}

php/test.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
require_once __DIR__ . '/gateio.php';
33

4-
$gate = new Gateio(12345,'server.ping', ["ETH_USDT", "BTC_USDT"]);
5-
64
$gate = new Gateio(rand(10,100000),'server.ping',[]);
75
//$gate = new Gateio(rand(10,100000),'server.time',[]);
86
//$gate = new Gateio(rand(10,100000),'ticker.query',["EOS_USDT",86400]);
@@ -22,8 +20,8 @@
2220

2321
//$gate = new Gateio(rand(10,100000),'kline.update',[1492358400,"7000.00","8000.0","8100.00","6800.00","1000.00","123456.00","BTC_USDT"]);
2422

25-
//$gate = new Gateio(rand(10,100000),'server.sign',[]);
26-
//$gate = new Gateio(rand(10,100000),'order.query',["BTC_USDT",0,10]);
23+
//$gate = new Gateio(rand(10,100000),'server.sign',[]);
24+
//$gate = new Gateio(rand(10,100000),'order.query',["BTC_USDT",0,10]);
2725
//$gate = new Gateio(rand(10,100000),'order.subscribe',["BTC_USDT"]);
2826
//$gate = new Gateio(rand(10,100000),'order.update',[2,"12345654654"]);
2927
//$gate = new Gateio(rand(10,100000),'order.unsubscribe',[]);
@@ -32,7 +30,5 @@
3230
//$gate = new Gateio(rand(10,100000),'balance.update',[]);
3331
//$gate = new Gateio(rand(10,100000),'balance.unsubscribe',[]);
3432

35-
$gate->request(function($data) {
36-
var_dump($data);
37-
});
33+
$gate->request();
3834

0 commit comments

Comments
 (0)