From 6c3ca467cd94c5924f967948c2179774a2489f84 Mon Sep 17 00:00:00 2001 From: "T.Todua" <7117978+ttodua@users.noreply.github.com> Date: Mon, 26 Dec 2022 18:04:22 +0400 Subject: [PATCH] balance examples fix --- examples/php/cobinhood-fetch-balance.php | 58 ------------------- ...ro-fetch-balance.php => fetch-balance.php} | 14 +---- 2 files changed, 3 insertions(+), 69 deletions(-) delete mode 100644 examples/php/cobinhood-fetch-balance.php rename examples/php/{vaultoro-fetch-balance.php => fetch-balance.php} (66%) diff --git a/examples/php/cobinhood-fetch-balance.php b/examples/php/cobinhood-fetch-balance.php deleted file mode 100644 index 0335333b4761..000000000000 --- a/examples/php/cobinhood-fetch-balance.php +++ /dev/null @@ -1,58 +0,0 @@ - 'YOUR_API_KEY', // edit this line - // 'secret' => 'COBINHOOD_DOES_NOT_USE_A_SECRET_KEY', - - // this is not required! uncomment only if you want to debug it - // 'verbose' => true, - -)); - -$message = null; - -try { - - $result = $exchange->fetch_balance(); - var_dump($result); - -// these catch-clauses are showing the proper way of handling the errors - -} catch (\ccxt\AuthenticationError $e) { - - // handle authentication error here - -} catch (\ccxt\NetworkError $e) { - - // your code to handle the network code and retries here - -} catch (\ccxt\ExchangeError $e) { - - // your code to handle an exchange error - -} catch (Exception $e) { - - // This is an example of how NOT TO DO error handling - // One should not rely on the message string contained in the exception - // If you want to access it, that might indicate a design error in your code. - // See: https://github.com/ccxt/ccxt/issues/3053 - - $message = $e->getMessage(); - - if (preg_match('/[a-z]+\s+(\{.+\})$/iu', $e->getMessage(), $matches)) { - $message = $matches[1]; - } - - echo print_r($message, true) . "\n"; - -} - -?> diff --git a/examples/php/vaultoro-fetch-balance.php b/examples/php/fetch-balance.php similarity index 66% rename from examples/php/vaultoro-fetch-balance.php rename to examples/php/fetch-balance.php index 5d6da1bb5aaf..4cfdc32643db 100644 --- a/examples/php/vaultoro-fetch-balance.php +++ b/examples/php/fetch-balance.php @@ -1,12 +1,9 @@ true, // for debugging // 'timeout' => 30000, "apiKey" => "YOUR_API_KEY", @@ -14,17 +11,12 @@ )); try { - + // about balance, read docs at : https://docs.ccxt.com/en/latest/manual.html?#balance-structure $result = $exchange->fetch_balance (); - print_r ($result); } catch (\ccxt\NetworkError $e) { echo '[Network Error] ' . $e->getMessage() . "\n"; -} catch (\ccxt\ExchangeError $e) { - echo '[Exchange Error] ' . $e->getMessage() . "\n"; } catch (Exception $e) { echo '[Error] ' . $e->getMessage() . "\n"; } - -?> \ No newline at end of file