From 0e9fd4033ff594a60fc212f86623d01f4898440c Mon Sep 17 00:00:00 2001 From: lin <465382251@qq.com> Date: Mon, 22 Jul 2019 17:02:00 +0800 Subject: [PATCH] Set the request timeout to 60 seconds by default --- src/OkexFuture.php | 9 +++++++++ src/OkexSpot.php | 9 +++++++++ src/OkexSwap.php | 9 +++++++++ tests/future/accounts.php | 3 +++ tests/spot/accounts.php | 3 +++ tests/swap/accounts.php | 5 ++++- 6 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/OkexFuture.php b/src/OkexFuture.php index 2554379..7912755 100644 --- a/src/OkexFuture.php +++ b/src/OkexFuture.php @@ -20,6 +20,7 @@ class OkexFuture protected $host; protected $proxy=false; + protected $timeout=60; function __construct(string $key='',string $secret='',string $passphrase='',string $host='https://www.okex.com'){ $this->key=$key; @@ -37,6 +38,7 @@ private function init(){ 'secret'=>$this->secret, 'passphrase'=>$this->passphrase, 'host'=>$this->host, + 'timeout'=>$this->timeout, ]; } @@ -57,6 +59,13 @@ function setProxy($proxy=true){ $this->proxy=$proxy; } + /** + * Set the request timeout to 60 seconds by default + * */ + function setTimeOut($timeout=60){ + $this->timeout=$timeout; + } + /** * * */ diff --git a/src/OkexSpot.php b/src/OkexSpot.php index 3ca1e62..aa07655 100644 --- a/src/OkexSpot.php +++ b/src/OkexSpot.php @@ -19,6 +19,7 @@ class OkexSpot protected $host; protected $proxy=false; + protected $timeout=60; function __construct(string $key='',string $secret='',string $passphrase='',string $host='https://www.okex.com'){ $this->key=$key; @@ -36,6 +37,7 @@ private function init(){ 'secret'=>$this->secret, 'passphrase'=>$this->passphrase, 'host'=>$this->host, + 'timeout'=>$this->timeout, ]; } @@ -56,6 +58,13 @@ function setProxy($proxy=true){ $this->proxy=$proxy; } + /** + * Set the request timeout to 60 seconds by default + * */ + function setTimeOut($timeout=60){ + $this->timeout=$timeout; + } + /** * * */ diff --git a/src/OkexSwap.php b/src/OkexSwap.php index c5f569c..ed22dca 100644 --- a/src/OkexSwap.php +++ b/src/OkexSwap.php @@ -21,6 +21,7 @@ class OkexSwap protected $host; protected $proxy=false; + protected $timeout=60; function __construct(string $key='',string $secret='',string $passphrase='',string $host='https://www.okex.com'){ $this->key=$key; @@ -38,6 +39,7 @@ private function init(){ 'secret'=>$this->secret, 'passphrase'=>$this->passphrase, 'host'=>$this->host, + 'timeout'=>$this->timeout, ]; } @@ -58,6 +60,13 @@ function setProxy($proxy=true){ $this->proxy=$proxy; } + /** + * Set the request timeout to 60 seconds by default + * */ + function setTimeOut($timeout=60){ + $this->timeout=$timeout; + } + /** * * */ diff --git a/tests/future/accounts.php b/tests/future/accounts.php index 5515617..7845719 100644 --- a/tests/future/accounts.php +++ b/tests/future/accounts.php @@ -17,6 +17,9 @@ $okex=new OkexFuture($key,$secret,$passphrase); +//Set the request timeout to 60 seconds by default +//$okex->setTimeOut(10); + //This endpoint supports getting the list of assets(only show pairs with balance larger than 0), the balances, amount available/on hold in spot accounts. try { $result=$okex->account()->getAll(); diff --git a/tests/spot/accounts.php b/tests/spot/accounts.php index 921fb5f..2fb1d0d 100644 --- a/tests/spot/accounts.php +++ b/tests/spot/accounts.php @@ -17,6 +17,9 @@ $okex=new OkexSpot($key,$secret,$passphrase); +//Set the request timeout to 60 seconds by default +//$okex->setTimeOut(10); + //This endpoint supports getting the list of assets(only show pairs with balance larger than 0), the balances, amount available/on hold in spot accounts. try { $result=$okex->account()->getAll(); diff --git a/tests/swap/accounts.php b/tests/swap/accounts.php index 90292aa..1ef794d 100644 --- a/tests/swap/accounts.php +++ b/tests/swap/accounts.php @@ -16,7 +16,10 @@ include 'key_secret.php'; $okex=new OkexSwap($key,$secret,$passphrase); -$okex->setProxy(); +//$okex->setProxy(); + +//Set the request timeout to 60 seconds by default +//$okex->setTimeOut(10); //This endpoint supports getting the list of assets(only show pairs with balance larger than 0), the balances, amount available/on hold in spot accounts. try {